Fix right + left shift optimization when shifting from long to int
This commit is contained in:
parent
7c11a5347c
commit
fdb051bd2b
|
@ -12180,13 +12180,15 @@ void InterCodeBasicBlock::PeepholeOptimization(const GrowingVariableArray& stati
|
|||
{
|
||||
|
||||
int shift = mInstructions[i + 0]->mSrc[0].mIntConst;
|
||||
if (shift & 7)
|
||||
{
|
||||
int mshift = mInstructions[i + 1]->mSrc[0].mIntConst;
|
||||
|
||||
mInstructions[i + 0]->mOperator = IA_AND;
|
||||
mInstructions[i + 0]->mSrc[0].mType = IT_INT16;
|
||||
mInstructions[i + 0]->mSrc[0].mType = mInstructions[i + 1]->mSrc[0].mType;
|
||||
|
||||
switch (mInstructions[i + 0]->mSrc[0].mType)
|
||||
switch (mInstructions[i + 0]->mSrc[1].mType)
|
||||
{
|
||||
case IT_INT8:
|
||||
mInstructions[i + 0]->mSrc[0].mIntConst = (0xffu >> shift) << shift;
|
||||
|
@ -12199,6 +12201,12 @@ void InterCodeBasicBlock::PeepholeOptimization(const GrowingVariableArray& stati
|
|||
break;
|
||||
}
|
||||
|
||||
if (shift > mshift && mInstructions[i + 0]->mDst.mType > mInstructions[i + 1]->mSrc[1].mType)
|
||||
{
|
||||
mInstructions[i + 1]->mSrc[1].mType = mInstructions[i + 0]->mDst.mType;
|
||||
mInstructions[i + 1]->mDst.mType = mInstructions[i + 0]->mDst.mType;
|
||||
}
|
||||
|
||||
if (shift > mshift)
|
||||
{
|
||||
mInstructions[i + 1]->mOperator = IA_SHR;
|
||||
|
@ -12218,6 +12226,7 @@ void InterCodeBasicBlock::PeepholeOptimization(const GrowingVariableArray& stati
|
|||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
else if (
|
||||
|
|
Loading…
Reference in New Issue