Fix constant fold of byte right shift
This commit is contained in:
parent
b61aa37f71
commit
d7c9f15593
|
@ -1201,25 +1201,11 @@ static int64 ConstantFolding(InterOperator oper, InterType type, int64 val1, int
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IA_SHL:
|
case IA_SHL:
|
||||||
return val1 << val2;
|
return ToTypedUnsigned(val1 << val2, type);
|
||||||
break;
|
|
||||||
case IA_SHR:
|
case IA_SHR:
|
||||||
return (uint64)val1 >> (uint64)val2;
|
return ToTypedUnsigned(val1, type) >> val2;
|
||||||
break;
|
|
||||||
case IA_SAR:
|
case IA_SAR:
|
||||||
|
return ToTypedSigned(val1, type) >> val2;
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case IT_INT8:
|
|
||||||
return int8(val1) >> val2;
|
|
||||||
case IT_INT16:
|
|
||||||
return int16(val1) >> val2;
|
|
||||||
case IT_INT32:
|
|
||||||
return int32(val1) >> val2;
|
|
||||||
default:
|
|
||||||
return val1 >> val2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IA_CMPEQ:
|
case IA_CMPEQ:
|
||||||
return ToTypedUnsigned(val1, type) == ToTypedUnsigned(val2, type) ? 1 : 0;
|
return ToTypedUnsigned(val1, type) == ToTypedUnsigned(val2, type) ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1686,7 +1672,7 @@ static InterOperand OperandConstantFolding(InterOperator oper, InterOperand op1,
|
||||||
break;
|
break;
|
||||||
case IA_SHL:
|
case IA_SHL:
|
||||||
dop.mType = op1.mType;
|
dop.mType = op1.mType;
|
||||||
dop.mIntConst = op1.mIntConst << op2.mIntConst;
|
dop.mIntConst = ToTypedUnsigned(op1.mIntConst << op2.mIntConst, op1.mType);
|
||||||
break;
|
break;
|
||||||
case IA_SHR:
|
case IA_SHR:
|
||||||
dop.mType = op1.mType;
|
dop.mType = op1.mType;
|
||||||
|
@ -22238,7 +22224,7 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
CheckFunc = !strcmp(mIdent->mString, "VLine");
|
CheckFunc = !strcmp(mIdent->mString, "main");
|
||||||
CheckCase = false;
|
CheckCase = false;
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
Loading…
Reference in New Issue