[llvm] r216947 - [FastISel] Provide the option to skip target-independent instruction selection. NFC.

Juergen Ributzka juergen at apple.com
Tue Sep 2 14:07:45 PDT 2014


Author: ributzka
Date: Tue Sep  2 16:07:44 2014
New Revision: 216947

URL: http://llvm.org/viewvc/llvm-project?rev=216947&view=rev
Log:
[FastISel] Provide the option to skip target-independent instruction selection. NFC.

This allows the target to disable target-independent instruction selection and
jump directly into the target-dependent instruction selection code.

This can be beneficial for targets, such as AArch64, which could emit much
better code, but never got a chance to do so, because the target-independent
instruction selector was able to find an instruction sequence.

Modified:
    llvm/trunk/include/llvm/CodeGen/FastISel.h
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp

Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=216947&r1=216946&r2=216947&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/FastISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/FastISel.h Tue Sep  2 16:07:44 2014
@@ -202,6 +202,7 @@ protected:
   const TargetLowering &TLI;
   const TargetRegisterInfo &TRI;
   const TargetLibraryInfo *LibInfo;
+  bool SkipTargetIndependentISel;
 
   /// The position of the last instruction for materializing constants for use
   /// in the current block. It resets to EmitStartPt when it makes sense (for
@@ -307,8 +308,9 @@ public:
   virtual ~FastISel();
 
 protected:
-  explicit FastISel(FunctionLoweringInfo &funcInfo,
-                    const TargetLibraryInfo *libInfo);
+  explicit FastISel(FunctionLoweringInfo &FuncInfo,
+                    const TargetLibraryInfo *LibInfo,
+                    bool SkipTargetIndependentISel = false);
 
   /// This method is called by target-independent code when the normal FastISel
   /// process fails to select an instruction.  This gives targets a chance to
@@ -545,7 +547,6 @@ protected:
     }
   }
 
-private:
   bool SelectBinaryOp(const User *I, unsigned ISDOpcode);
 
   bool SelectFNeg(const User *I);
@@ -566,6 +567,7 @@ private:
 
   bool SelectInsertValue(const User *I);
 
+private:
   /// \brief Handle PHI nodes in successor blocks.
   ///
   /// Emit code to ensure constants are copied into registers when needed.

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=216947&r1=216946&r2=216947&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Sep  2 16:07:44 2014
@@ -1344,8 +1344,24 @@ FastISel::SelectInstruction(const Instru
   }
 
   // First, try doing target-independent selection.
-  if (SelectOperator(I, I->getOpcode())) {
-    ++NumFastIselSuccessIndependent;
+  if (!SkipTargetIndependentISel) {
+    if (SelectOperator(I, I->getOpcode())) {
+      ++NumFastIselSuccessIndependent;
+      DbgLoc = DebugLoc();
+      return true;
+    }
+    // Remove dead code.  However, ignore call instructions since we've flushed
+    // the local value map and recomputed the insert point.
+    if (!isa<CallInst>(I)) {
+      recomputeInsertPt();
+      if (SavedInsertPt != FuncInfo.InsertPt)
+        removeDeadCode(FuncInfo.InsertPt, SavedInsertPt);
+    }
+    SavedInsertPt = FuncInfo.InsertPt;
+  }
+  // Next, try calling the target to attempt to handle the instruction.
+  if (TargetSelectInstruction(I)) {
+    ++NumFastIselSuccessTarget;
     DbgLoc = DebugLoc();
     return true;
   }
@@ -1357,18 +1373,6 @@ FastISel::SelectInstruction(const Instru
       removeDeadCode(FuncInfo.InsertPt, SavedInsertPt);
   }
 
-  // Next, try calling the target to attempt to handle the instruction.
-  SavedInsertPt = FuncInfo.InsertPt;
-  if (TargetSelectInstruction(I)) {
-    ++NumFastIselSuccessTarget;
-    DbgLoc = DebugLoc();
-    return true;
-  }
-  // Check for dead code and remove as necessary.
-  recomputeInsertPt();
-  if (SavedInsertPt != FuncInfo.InsertPt)
-    removeDeadCode(FuncInfo.InsertPt, SavedInsertPt);
-
   DbgLoc = DebugLoc();
   // Undo phi node updates, because they will be added again by SelectionDAG.
   if (isa<TerminatorInst>(I))
@@ -1603,14 +1607,16 @@ FastISel::SelectOperator(const User *I,
   }
 }
 
-FastISel::FastISel(FunctionLoweringInfo &funcInfo,
-                   const TargetLibraryInfo *libInfo)
-    : FuncInfo(funcInfo), MF(funcInfo.MF), MRI(FuncInfo.MF->getRegInfo()),
+FastISel::FastISel(FunctionLoweringInfo &FuncInfo,
+                   const TargetLibraryInfo *LibInfo,
+                   bool SkipTargetIndependentISel)
+    : FuncInfo(FuncInfo), MF(FuncInfo.MF), MRI(FuncInfo.MF->getRegInfo()),
       MFI(*FuncInfo.MF->getFrameInfo()), MCP(*FuncInfo.MF->getConstantPool()),
       TM(FuncInfo.MF->getTarget()), DL(*TM.getSubtargetImpl()->getDataLayout()),
       TII(*TM.getSubtargetImpl()->getInstrInfo()),
       TLI(*TM.getSubtargetImpl()->getTargetLowering()),
-      TRI(*TM.getSubtargetImpl()->getRegisterInfo()), LibInfo(libInfo) {}
+      TRI(*TM.getSubtargetImpl()->getRegisterInfo()), LibInfo(LibInfo),
+      SkipTargetIndependentISel(SkipTargetIndependentISel) {}
 
 FastISel::~FastISel() {}
 





More information about the llvm-commits mailing list