Native code peephole optimisation for commutative instructions
This commit is contained in:
parent
d3d20bee26
commit
78886f11f7
|
@ -71,7 +71,7 @@ bool NativeCodeInstruction::IsUsedResultInstructions(NumberSet& requiredTemps)
|
||||||
mLive |= LIVE_CPU_REG_Z;
|
mLive |= LIVE_CPU_REG_Z;
|
||||||
if (requiredTemps[CPU_REG_C])
|
if (requiredTemps[CPU_REG_C])
|
||||||
mLive |= LIVE_CPU_REG_C;
|
mLive |= LIVE_CPU_REG_C;
|
||||||
if (mMode == ASMIM_ZERO_PAGE)
|
if (mMode == ASMIM_ZERO_PAGE && requiredTemps[mAddress])
|
||||||
mLive |= LIVE_MEM;
|
mLive |= LIVE_MEM;
|
||||||
|
|
||||||
if (mType == ASMIT_JSR)
|
if (mType == ASMIT_JSR)
|
||||||
|
@ -446,6 +446,11 @@ bool NativeCodeInstruction::ChangesAddress(void) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeCodeInstruction::IsCommutative(void) const
|
||||||
|
{
|
||||||
|
return mType == ASMIT_ADC || mType == ASMIT_AND || mType == ASMIT_ORA || mType == ASMIT_EOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NativeCodeInstruction::SameEffectiveAddress(const NativeCodeInstruction& ins) const
|
bool NativeCodeInstruction::SameEffectiveAddress(const NativeCodeInstruction& ins) const
|
||||||
{
|
{
|
||||||
|
@ -4080,6 +4085,16 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
||||||
mIns[i + 2].mType = ASMIT_STA;
|
mIns[i + 2].mType = ASMIT_STA;
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
|
else if (mIns[i + 0].mType == ASMIT_STA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
|
||||||
|
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode != ASMIM_ZERO_PAGE &&
|
||||||
|
mIns[i + 2].mMode == ASMIM_ZERO_PAGE && mIns[i + 0].mAddress == mIns[i + 2].mAddress &&
|
||||||
|
mIns[i + 2].IsCommutative() && HasAsmInstructionMode(mIns[i + 2].mType, mIns[i + 1].mMode) &&
|
||||||
|
(mIns[i + 2].mLive & LIVE_MEM) == 0)
|
||||||
|
{
|
||||||
|
mIns[i + 1].mType = mIns[i + 2].mType;
|
||||||
|
mIns[i + 0].mType = ASMIT_NOP;
|
||||||
|
mIns[i + 2].mType = ASMIT_NOP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i + 3 < mIns.Size())
|
if (i + 3 < mIns.Size())
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
bool LoadsAccu(void) const;
|
bool LoadsAccu(void) const;
|
||||||
bool ChangesAddress(void) const;
|
bool ChangesAddress(void) const;
|
||||||
bool SameEffectiveAddress(const NativeCodeInstruction& ins) const;
|
bool SameEffectiveAddress(const NativeCodeInstruction& ins) const;
|
||||||
|
bool IsCommutative(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NativeCodeBasicBlock
|
class NativeCodeBasicBlock
|
||||||
|
|
Loading…
Reference in New Issue