summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-09-10 23:34:19 +0000
committerBill Wendling <isanbard@gmail.com>2010-09-10 23:34:19 +0000
commit041230014cfcac43b7a7204ee5ef8c4dd42f599e (patch)
tree6b171bdbbad3dab9f73532c5ce394431424f9e33 /llvm/lib/Target/ARM
parenta8bac37bb1141f046286e2f246a4ecc470509a46 (diff)
downloadbcm5719-llvm-041230014cfcac43b7a7204ee5ef8c4dd42f599e.tar.gz
bcm5719-llvm-041230014cfcac43b7a7204ee5ef8c4dd42f599e.zip
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. llvm-svn: 113665
Diffstat (limited to 'llvm/lib/Target/ARM')
-rw-r--r--llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp21
-rw-r--r--llvm/lib/Target/ARM/ARMBaseInstrInfo.h3
2 files changed, 18 insertions, 6 deletions
diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
index 142633c667f..a73e7ad44db 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -1377,12 +1377,25 @@ AnalyzeCompare(const MachineInstr *MI, unsigned &SrcReg, int &CmpValue) const {
return false;
}
-/// ConvertToSetZeroFlag - Convert the instruction to set the "zero" flag so
-/// that we can remove a "comparison with zero". Update the iterator *only* if a
-/// transformation took place.
+/// ConvertToSetZeroFlag - Convert the instruction supplying the argument to the
+/// 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 *MI, MachineInstr *CmpInstr,
+ConvertToSetZeroFlag(MachineInstr *CmpInstr,
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
// as the comparison.
if (MI->getParent() != CmpInstr->getParent())
diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
index 622402eba35..2be0d3687d2 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
@@ -346,8 +346,7 @@ public:
/// ConvertToSetZeroFlag - Convert the instruction to set the zero flag so
/// that we can remove a "comparison with zero".
- virtual bool ConvertToSetZeroFlag(MachineInstr *Instr,
- MachineInstr *CmpInstr,
+ virtual bool ConvertToSetZeroFlag(MachineInstr *CmpInstr,
MachineBasicBlock::iterator &MII) const;
virtual unsigned getNumMicroOps(const MachineInstr *MI,
OpenPOWER on IntegriCloud