Pass AliasAnalysis thru to DAGCombiner.
authorJim Laskey <jlaskey@mac.com>
Mon, 16 Oct 2006 20:52:31 +0000 (20:52 +0000)
committerJim Laskey <jlaskey@mac.com>
Mon, 16 Oct 2006 20:52:31 +0000 (20:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30984 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAG.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 65448c78a6d210d37d7c541dc5852d9f3697ef52..144b9d5eaa73e589be70266637620dffd54ef103 100644 (file)
@@ -25,6 +25,7 @@
 #include <string>
 
 namespace llvm {
+  class AliasAnalysis;
   class TargetLowering;
   class TargetMachine;
   class MachineDebugInfo;
@@ -116,7 +117,7 @@ public:
   /// certain types of nodes together, or eliminating superfluous nodes.  When
   /// the AfterLegalize argument is set to 'true', Combine takes care not to
   /// generate any nodes that will be illegal on the target.
-  void Combine(bool AfterLegalize);
+  void Combine(bool AfterLegalize, AliasAnalysis &AA);
   
   /// Legalize - This transforms the SelectionDAG into a SelectionDAG that is
   /// compatible with the target instruction selector, as indicated by the
index 1cac34d8d8cdc13ef30b185936d8d10bea500028..ba90e23b04ed2f25871408e1c5e3ff371a3aa285 100644 (file)
@@ -30,6 +30,7 @@
 
 #define DEBUG_TYPE "dagcombine"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/CodeGen/SelectionDAG.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
@@ -60,6 +61,9 @@ namespace {
     // Worklist of all of the nodes that need to be simplified.
     std::vector<SDNode*> WorkList;
 
+    // AA - Used for DAG load/store alias analysis.
+    AliasAnalysis &AA;
+
     /// AddUsersToWorkList - When an instruction is simplified, add all users of
     /// the instruction to the work lists because they might get more simplified
     /// now.
@@ -262,8 +266,11 @@ namespace {
     SDOperand FindBetterChain(SDNode *N, SDOperand Chain);
     
 public:
-    DAGCombiner(SelectionDAG &D)
-      : DAG(D), TLI(D.getTargetLoweringInfo()), AfterLegalize(false) {}
+    DAGCombiner(SelectionDAG &D, AliasAnalysis &A)
+      : DAG(D),
+        TLI(D.getTargetLoweringInfo()),
+        AfterLegalize(false),
+        AA(A) {}
     
     /// Run - runs the dag combiner on all nodes in the work list
     void Run(bool RunningAfterLegalize); 
@@ -4133,8 +4140,8 @@ SDOperand DAGCombiner::FindBetterChain(SDNode *N, SDOperand OldChain) {
 
 // SelectionDAG::Combine - This is the entry point for the file.
 //
-void SelectionDAG::Combine(bool RunningAfterLegalize) {
+void SelectionDAG::Combine(bool RunningAfterLegalize, AliasAnalysis &AA) {
   /// run - This is the main entry point to this class.
   ///
-  DAGCombiner(*this).Run(RunningAfterLegalize);
+  DAGCombiner(*this, AA).Run(RunningAfterLegalize);
 }
index 17210ca4d5aa7455c28323f2dbf78c38fc81cda5..3064285876ff7c5a45a6bd7d0306fcef8a4c1cb2 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "isel"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/CodeGen/SelectionDAGISel.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
 #include "llvm/CallingConv.h"
@@ -2951,6 +2952,7 @@ unsigned SelectionDAGISel::MakeReg(MVT::ValueType VT) {
 void SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) const {
   // FIXME: we only modify the CFG to split critical edges.  This
   // updates dom and loop info.
+  AU.addRequired<AliasAnalysis>();
 }
 
 
@@ -3546,8 +3548,11 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
 }
 
 void SelectionDAGISel::CodeGenAndEmitDAG(SelectionDAG &DAG) {
+  // Get alias analysis for load/store combining.
+  AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
+
   // Run the DAG combiner in pre-legalize mode.
-  DAG.Combine(false);
+  DAG.Combine(false, AA);
   
   DEBUG(std::cerr << "Lowered selection DAG:\n");
   DEBUG(DAG.dump());
@@ -3560,7 +3565,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG(SelectionDAG &DAG) {
   DEBUG(DAG.dump());
   
   // Run the DAG combiner in post-legalize mode.
-  DAG.Combine(true);
+  DAG.Combine(true, AA);
   
   if (ViewISelDAGs) DAG.viewGraph();