diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index c0baec3808c..29fbe8217fe 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -589,6 +589,7 @@ public: /// the comparison into one that sets the zero bit in the flags /// register. Update the iterator *only* if a transformation took place. virtual bool ConvertToSetZeroFlag(MachineInstr * /*CmpInstr*/, + unsigned /*SrcReg*/, int /*CmpValue*/, MachineBasicBlock::iterator &) const { return false; } diff --git a/lib/CodeGen/PeepholeOptimizer.cpp b/lib/CodeGen/PeepholeOptimizer.cpp index 7a1bf4050df..529f994f003 100644 --- a/lib/CodeGen/PeepholeOptimizer.cpp +++ b/lib/CodeGen/PeepholeOptimizer.cpp @@ -244,7 +244,7 @@ bool PeepholeOptimizer::OptimizeCmpInstr(MachineInstr *MI, return false; // Attempt to convert the defining instruction to set the "zero" flag. - if (TII->ConvertToSetZeroFlag(MI, NextIter)) { + if (TII->ConvertToSetZeroFlag(MI, SrcReg, CmpValue, NextIter)) { ++NumEliminated; return true; } diff --git a/lib/Target/ARM/ARMBaseInstrInfo.cpp b/lib/Target/ARM/ARMBaseInstrInfo.cpp index a73e7ad44db..d79905a80b9 100644 --- a/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -1381,11 +1381,9 @@ AnalyzeCompare(const MachineInstr *MI, unsigned &SrcReg, int &CmpValue) const { /// comparison into one that sets the zero bit in the flags register. Update the /// iterator *only* if a transformation took place. bool ARMBaseInstrInfo:: -ConvertToSetZeroFlag(MachineInstr *CmpInstr, +ConvertToSetZeroFlag(MachineInstr *CmpInstr, unsigned SrcReg, int CmpValue, MachineBasicBlock::iterator &MII) const { - unsigned SrcReg; - int CmpValue; - if (!AnalyzeCompare(CmpInstr, SrcReg, CmpValue) || CmpValue != 0) + if (CmpValue != 0) return false; MachineRegisterInfo &MRI = CmpInstr->getParent()->getParent()->getRegInfo(); diff --git a/lib/Target/ARM/ARMBaseInstrInfo.h b/lib/Target/ARM/ARMBaseInstrInfo.h index 2be0d3687d2..e76e2fe4023 100644 --- a/lib/Target/ARM/ARMBaseInstrInfo.h +++ b/lib/Target/ARM/ARMBaseInstrInfo.h @@ -346,7 +346,8 @@ public: /// ConvertToSetZeroFlag - Convert the instruction to set the zero flag so /// that we can remove a "comparison with zero". - virtual bool ConvertToSetZeroFlag(MachineInstr *CmpInstr, + virtual bool ConvertToSetZeroFlag(MachineInstr *CmpInstr, unsigned SrcReg, + int CmpValue, MachineBasicBlock::iterator &MII) const; virtual unsigned getNumMicroOps(const MachineInstr *MI,