[llvm-commits] [llvm] r115339 - in /llvm/trunk/lib/Target/ARM: Thumb2InstrInfo.cpp Thumb2InstrInfo.h

Owen Anderson resistor at mac.com
Fri Oct 1 13:28:06 PDT 2010


Author: resistor
Date: Fri Oct  1 15:28:06 2010
New Revision: 115339

URL: http://llvm.org/viewvc/llvm-project?rev=115339&view=rev
Log:
Provide an option to restore old-style if-conversion heuristics for Thumb2.

Modified:
    llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp
    llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h

Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=115339&r1=115338&r2=115339&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Fri Oct  1 15:28:06 2010
@@ -28,6 +28,11 @@
 
 using namespace llvm;
 
+static cl::opt<bool>
+OldT2IfCvt("old-thumb2-ifcvt", cl::Hidden,
+           cl::desc("Use old-style Thumb2 if-conversion heuristics"),
+           cl::init(false));
+
 Thumb2InstrInfo::Thumb2InstrInfo(const ARMSubtarget &STI)
   : ARMBaseInstrInfo(STI), RI(*this, STI) {
 }
@@ -37,6 +42,30 @@
   return 0;
 }
 
+bool Thumb2InstrInfo::isProfitableToIfCvt(MachineBasicBlock &MBB,
+                                          unsigned NumInstrs,
+                                          float Prediction) const {
+  if (!OldT2IfCvt)
+    return ARMBaseInstrInfo::isProfitableToIfCvt(MBB, NumInstrs, Prediction);
+  return NumInstrs && NumInstrs <= 3;
+}
+  
+bool Thumb2InstrInfo::
+isProfitableToIfCvt(MachineBasicBlock &TMBB, unsigned NumT,
+                    MachineBasicBlock &FMBB, unsigned NumF,
+                    float Prediction) const {
+  if (!OldT2IfCvt)
+    return ARMBaseInstrInfo::isProfitableToIfCvt(TMBB, NumT,
+                                                 FMBB, NumF, Prediction);
+    
+  // FIXME: Catch optimization such as:
+  //        r0 = movne
+  //        r0 = moveq
+  return NumT && NumF &&
+    NumT <= 3 && NumF <= 3;
+}
+
+
 void
 Thumb2InstrInfo::ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail,
                                          MachineBasicBlock *NewDest) const {

Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=115339&r1=115338&r2=115339&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original)
+++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Fri Oct  1 15:28:06 2010
@@ -38,6 +38,12 @@
   bool isLegalToSplitMBBAt(MachineBasicBlock &MBB,
                            MachineBasicBlock::iterator MBBI) const;
 
+  bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumInstrs,
+                           float Prediction) const;
+  bool isProfitableToIfCvt(MachineBasicBlock &TMBB, unsigned NumTInstrs,
+                           MachineBasicBlock &FMBB, unsigned NumFInstrs,
+                           float Prediction) const;
+
   void copyPhysReg(MachineBasicBlock &MBB,
                    MachineBasicBlock::iterator I, DebugLoc DL,
                    unsigned DestReg, unsigned SrcReg,





More information about the llvm-commits mailing list