Lett users of sparse propagation do their own thing with phi nodes if they want
authorNick Lewycky <nicholas@mxc.ca>
Sat, 19 Sep 2009 18:33:36 +0000 (18:33 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sat, 19 Sep 2009 18:33:36 +0000 (18:33 +0000)
to. This can be combined with LCSSA or SSI form to store more information on a
PHINode than can be computed by looking at its incoming values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82317 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/SparsePropagation.h
lib/Analysis/SparsePropagation.cpp

index cc655aa85fdf8d9ef18ab3129ee87e9baa16b239..820e1bd1e436bab49e1c110be4579205837ab54f 100644 (file)
@@ -72,6 +72,12 @@ public:
   virtual LatticeVal ComputeConstant(Constant *C) {
     return getOverdefinedVal(); // always safe
   }
+
+  /// IsSpecialCasedPHI - Given a PHI node, determine whether this PHI node is
+  /// one that the we want to handle through ComputeInstructionState.
+  virtual bool IsSpecialCasedPHI(PHINode *PN) {
+    return false;
+  }
   
   /// GetConstant - If the specified lattice value is representable as an LLVM
   /// constant value, return it.  Otherwise return null.  The returned value
index 17bb73f991e48f2ea3e5849f4ce577cb37ea5e88..8a74745dd3fb62c379f3e9bbc0079117fd10234d 100644 (file)
@@ -223,6 +223,13 @@ void SparseSolver::visitTerminatorInst(TerminatorInst &TI) {
 }
 
 void SparseSolver::visitPHINode(PHINode &PN) {
+  if (LatticeFunc->IsSpecialCasedPHI(&PN)) {
+    LatticeVal IV = LatticeFunc->ComputeInstructionState(PN, *this);
+    if (IV != LatticeFunc->getUntrackedVal())
+      UpdateState(PN, IV);
+    return;
+  }
+
   LatticeVal PNIV = getOrInitValueState(&PN);
   LatticeVal Overdefined = LatticeFunc->getOverdefinedVal();