[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp SelectionDAGISel.cpp

Nate Begeman natebegeman at mac.com
Tue Sep 6 17:15:48 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.5 -> 1.6
SelectionDAGISel.cpp updated: 1.81 -> 1.82
---
Log message:

Add an option to the DAG Combiner to enable it for beta runs, and turn on
that option for PowerPC's beta.


---
Diffs of the changes:  (+25 -5)

 DAGCombiner.cpp      |   11 ++++++-----
 SelectionDAGISel.cpp |   19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.5 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.6
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.5	Mon Sep  5 23:43:02 2005
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Tue Sep  6 19:15:36 2005
@@ -37,6 +37,7 @@
 #define DEBUG_TYPE "dagcombine"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Target/TargetLowering.h"
 #include <cmath>
@@ -76,8 +77,8 @@
     // Visitation implementation - Implement dag node combining for different
     // node types.  The semantics are as follows:
     // Return Value:
-    //    null        - No change was made
-    //   otherwise    - Node N should be replaced by the returned node.
+    //   SDOperand.Val == 0   - No change was made
+    //   otherwise            - N should be replaced by the returned Operand.
     //
     SDOperand visitTokenFactor(SDNode *N);
     SDOperand visitADD(SDNode *N);
@@ -266,9 +267,9 @@
       // CombineTo was used.  Since CombineTo takes care of the worklist 
       // mechanics for us, we have no work to do in this case.
       if (RV.Val != N) {
-        std::cerr << "\nReplacing "; N->dump();
-        std::cerr << "\nWith: "; RV.Val->dump();
-        std::cerr << '\n';
+        DEBUG(std::cerr << "\nReplacing "; N->dump();
+              std::cerr << "\nWith: "; RV.Val->dump();
+              std::cerr << '\n');
         DAG.ReplaceAllUsesWith(SDOperand(N, 0), RV);
           
         // Push the new node and any users onto the worklist


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.81 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.82
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.81	Fri Sep  2 13:41:28 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Tue Sep  6 19:15:36 2005
@@ -36,6 +36,18 @@
 #include <iostream>
 using namespace llvm;
 
+// Temporary command line code to enable use of the dag combiner as a beta
+// option.
+namespace llvm {
+  bool CombinerEnabled;
+}
+namespace {
+  cl::opt<bool, true>
+  CombineDAG("enable-dag-combiner", cl::Hidden,
+             cl::desc("Run the DAG combiner before and after Legalize"),
+             cl::location(CombinerEnabled),
+             cl::init(false));
+}
 #ifndef NDEBUG
 static cl::opt<bool>
 ViewDAGs("view-isel-dags", cl::Hidden,
@@ -44,6 +56,7 @@
 static const bool ViewDAGs = 0;
 #endif
 
+
 namespace llvm {
   //===--------------------------------------------------------------------===//
   /// FunctionLoweringInfo - This contains information that is global to a
@@ -1234,6 +1247,9 @@
   // types that are not supported by the target.
   BuildSelectionDAG(DAG, LLVMBB, PHINodesToUpdate, FuncInfo);
 
+  // Run the DAG combiner in pre-legalize mode, if we are told to do so
+  if (CombinerEnabled) DAG.Combine(false);
+  
   DEBUG(std::cerr << "Lowered selection DAG:\n");
   DEBUG(DAG.dump());
 
@@ -1246,6 +1262,9 @@
 
   if (ViewDAGs) DAG.viewGraph();
 
+  // Run the DAG combiner in post-legalize mode, if we are told to do so
+  if (CombinerEnabled) DAG.Combine(true);
+  
   // Third, instruction select all of the operations to machine code, adding the
   // code to the MachineBasicBlock.
   InstructionSelectBasicBlock(DAG);






More information about the llvm-commits mailing list