[PATCH] D79112: [SelectionDAG] Add the option of disabling generic combines.

Marcello Maggioni via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 12:22:28 PDT 2020


kariddi created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
kariddi edited the summary of this revision.
kariddi added reviewers: bogner, RKSimon, ThomasRaoux.

For some targets generic combines don't really do much and they
consume a disproportionate amount of time.
There's not really a mechanism in SDISel to tactically disable
combines, but we can have a switch to disable all of them and
let the targets just implement what they specifically need.

Tested compile time performance on LNT Nightly and didn't make any effect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79112

Files:
  llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -130,6 +130,7 @@
   class DAGCombiner {
     SelectionDAG &DAG;
     const TargetLowering &TLI;
+    const SelectionDAGTargetInfo &STI;
     CombineLevel Level;
     CodeGenOpt::Level OptLevel;
     bool LegalDAG = false;
@@ -223,8 +224,8 @@
 
   public:
     DAGCombiner(SelectionDAG &D, AliasAnalysis *AA, CodeGenOpt::Level OL)
-        : DAG(D), TLI(D.getTargetLoweringInfo()), Level(BeforeLegalizeTypes),
-          OptLevel(OL), AA(AA) {
+        : DAG(D), TLI(D.getTargetLoweringInfo()), STI(D.getSelectionDAGInfo()),
+          Level(BeforeLegalizeTypes), OptLevel(OL), AA(AA) {
       ForCodeSize = DAG.shouldOptForSize();
 
       MaximumLegalStoreInBits = 0;
@@ -1649,7 +1650,9 @@
 }
 
 SDValue DAGCombiner::combine(SDNode *N) {
-  SDValue RV = visit(N);
+  SDValue RV;
+  if (STI.runGenericCombines(OptLevel))
+    RV = visit(N);
 
   // If nothing happened, try a target-specific DAG combine.
   if (!RV.getNode()) {
@@ -11747,8 +11750,7 @@
   if (!AllowFusionGlobally && !isContractable(N))
     return SDValue();
 
-  const SelectionDAGTargetInfo *STI = DAG.getSubtarget().getSelectionDAGInfo();
-  if (STI && STI->generateFMAsInMachineCombiner(OptLevel))
+  if (STI.generateFMAsInMachineCombiner(OptLevel))
     return SDValue();
 
   // Always prefer FMAD to FMA for precision.
@@ -11965,8 +11967,7 @@
   if (!AllowFusionGlobally && !isContractable(N))
     return SDValue();
 
-  const SelectionDAGTargetInfo *STI = DAG.getSubtarget().getSelectionDAGInfo();
-  if (STI && STI->generateFMAsInMachineCombiner(OptLevel))
+  if (STI.generateFMAsInMachineCombiner(OptLevel))
     return SDValue();
 
   // Always prefer FMAD to FMA for precision.
Index: llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h
+++ llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h
@@ -160,6 +160,11 @@
   virtual bool generateFMAsInMachineCombiner(CodeGenOpt::Level OptLevel) const {
     return false;
   }
+
+  // Return true if the Machine Combiner should run generic combines.
+  virtual bool runGenericCombines(CodeGenOpt::Level OptLevel) const {
+    return true;
+  }
 };
 
 } // end namespace llvm


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79112.260980.patch
Type: text/x-patch
Size: 2444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/86e55755/attachment.bin>


More information about the llvm-commits mailing list