Don't recompute MachineRegisterInfo in the Optimize* method.

llvm-svn: 116750
This commit is contained in:
Bill Wendling 2010-10-18 21:22:31 +00:00
parent cf2afe008d
commit 337a31133b
4 changed files with 9 additions and 7 deletions

View File

@ -600,6 +600,7 @@ public:
/// *only* if a transformation took place.
virtual bool OptimizeCompareInstr(MachineInstr *CmpInstr,
unsigned SrcReg, int Mask, int Value,
const MachineRegisterInfo *MRI,
MachineBasicBlock::iterator &) const {
return false;
}

View File

@ -247,7 +247,7 @@ bool PeepholeOptimizer::OptimizeCmpInstr(MachineInstr *MI,
return false;
// Attempt to optimize the comparison instruction.
if (TII->OptimizeCompareInstr(MI, SrcReg, CmpMask, CmpValue, NextIter)) {
if (TII->OptimizeCompareInstr(MI, SrcReg, CmpMask, CmpValue, MRI, NextIter)) {
++NumEliminated;
return true;
}

View File

@ -1490,13 +1490,13 @@ static bool isSuitableForMask(MachineInstr *&MI, unsigned SrcReg,
/// iterator *only* if a transformation took place.
bool ARMBaseInstrInfo::
OptimizeCompareInstr(MachineInstr *CmpInstr, unsigned SrcReg, int CmpMask,
int CmpValue, MachineBasicBlock::iterator &MII) const {
int CmpValue, const MachineRegisterInfo *MRI,
MachineBasicBlock::iterator &MII) const {
if (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())
MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg);
if (llvm::next(DI) != MRI->def_end())
// Only support one definition.
return false;
@ -1506,8 +1506,8 @@ OptimizeCompareInstr(MachineInstr *CmpInstr, unsigned SrcReg, int CmpMask,
if (CmpMask != ~0) {
if (!isSuitableForMask(MI, SrcReg, CmpMask, false)) {
MI = 0;
for (MachineRegisterInfo::use_iterator UI = MRI.use_begin(SrcReg),
UE = MRI.use_end(); UI != UE; ++UI) {
for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(SrcReg),
UE = MRI->use_end(); UI != UE; ++UI) {
if (UI->getParent() != CmpInstr->getParent()) continue;
MachineInstr *PotentialAND = &*UI;
if (!isSuitableForMask(PotentialAND, SrcReg, CmpMask, true))

View File

@ -341,6 +341,7 @@ public:
/// that we can remove a "comparison with zero".
virtual bool OptimizeCompareInstr(MachineInstr *CmpInstr, unsigned SrcReg,
int CmpMask, int CmpValue,
const MachineRegisterInfo *MRI,
MachineBasicBlock::iterator &MII) const;
virtual unsigned getNumMicroOps(const MachineInstr *MI,