mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 18:24:00 +00:00
Move some of the decision logic for converting an instruction into one that sets
the 'zero' bit down into the back-end. There are other cases where this logic isn't sufficient, so they should be handled separately. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113665 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -585,11 +585,10 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ConvertToSetZeroFlag - Convert the instruction to set the zero flag so
|
/// ConvertToSetZeroFlag - Convert the instruction supplying the argument to
|
||||||
/// that we can remove a "comparison with zero". Update the iterator *only*
|
/// the comparison into one that sets the zero bit in the flags
|
||||||
/// if a transformation took place.
|
/// register. Update the iterator *only* if a transformation took place.
|
||||||
virtual bool ConvertToSetZeroFlag(MachineInstr * /*Instr*/,
|
virtual bool ConvertToSetZeroFlag(MachineInstr * /*CmpInstr*/,
|
||||||
MachineInstr * /*CmpInstr*/,
|
|
||||||
MachineBasicBlock::iterator &) const {
|
MachineBasicBlock::iterator &) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -240,16 +240,11 @@ bool PeepholeOptimizer::OptimizeCmpInstr(MachineInstr *MI,
|
|||||||
unsigned SrcReg;
|
unsigned SrcReg;
|
||||||
int CmpValue;
|
int CmpValue;
|
||||||
if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) ||
|
if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) ||
|
||||||
TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0)
|
TargetRegisterInfo::isPhysicalRegister(SrcReg))
|
||||||
return false;
|
|
||||||
|
|
||||||
MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg);
|
|
||||||
if (llvm::next(DI) != MRI->def_end())
|
|
||||||
// Only support one definition.
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Attempt to convert the defining instruction to set the "zero" flag.
|
// Attempt to convert the defining instruction to set the "zero" flag.
|
||||||
if (TII->ConvertToSetZeroFlag(&*DI, MI, NextIter)) {
|
if (TII->ConvertToSetZeroFlag(MI, NextIter)) {
|
||||||
++NumEliminated;
|
++NumEliminated;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1377,12 +1377,25 @@ AnalyzeCompare(const MachineInstr *MI, unsigned &SrcReg, int &CmpValue) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ConvertToSetZeroFlag - Convert the instruction to set the "zero" flag so
|
/// ConvertToSetZeroFlag - Convert the instruction supplying the argument to the
|
||||||
/// that we can remove a "comparison with zero". Update the iterator *only* if a
|
/// comparison into one that sets the zero bit in the flags register. Update the
|
||||||
/// transformation took place.
|
/// iterator *only* if a transformation took place.
|
||||||
bool ARMBaseInstrInfo::
|
bool ARMBaseInstrInfo::
|
||||||
ConvertToSetZeroFlag(MachineInstr *MI, MachineInstr *CmpInstr,
|
ConvertToSetZeroFlag(MachineInstr *CmpInstr,
|
||||||
MachineBasicBlock::iterator &MII) const {
|
MachineBasicBlock::iterator &MII) const {
|
||||||
|
unsigned SrcReg;
|
||||||
|
int CmpValue;
|
||||||
|
if (!AnalyzeCompare(CmpInstr, SrcReg, CmpValue) || CmpValue != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
MachineRegisterInfo &MRI = CmpInstr->getParent()->getParent()->getRegInfo();
|
||||||
|
MachineRegisterInfo::def_iterator DI = MRI.def_begin(SrcReg);
|
||||||
|
if (llvm::next(DI) != MRI.def_end())
|
||||||
|
// Only support one definition.
|
||||||
|
return false;
|
||||||
|
|
||||||
|
MachineInstr *MI = &*DI;
|
||||||
|
|
||||||
// Conservatively refuse to convert an instruction which isn't in the same BB
|
// Conservatively refuse to convert an instruction which isn't in the same BB
|
||||||
// as the comparison.
|
// as the comparison.
|
||||||
if (MI->getParent() != CmpInstr->getParent())
|
if (MI->getParent() != CmpInstr->getParent())
|
||||||
|
@ -346,8 +346,7 @@ public:
|
|||||||
|
|
||||||
/// ConvertToSetZeroFlag - Convert the instruction to set the zero flag so
|
/// ConvertToSetZeroFlag - Convert the instruction to set the zero flag so
|
||||||
/// that we can remove a "comparison with zero".
|
/// that we can remove a "comparison with zero".
|
||||||
virtual bool ConvertToSetZeroFlag(MachineInstr *Instr,
|
virtual bool ConvertToSetZeroFlag(MachineInstr *CmpInstr,
|
||||||
MachineInstr *CmpInstr,
|
|
||||||
MachineBasicBlock::iterator &MII) const;
|
MachineBasicBlock::iterator &MII) const;
|
||||||
|
|
||||||
virtual unsigned getNumMicroOps(const MachineInstr *MI,
|
virtual unsigned getNumMicroOps(const MachineInstr *MI,
|
||||||
|
Reference in New Issue
Block a user