[llvm-commits] [llvm] r86920 - in /llvm/trunk: include/llvm/Analysis/LazyValueInfo.h lib/Analysis/LazyValueInfo.cpp lib/Transforms/Scalar/JumpThreading.cpp

Chris Lattner sabre at nondot.org
Wed Nov 11 17:29:10 PST 2009


Author: lattner
Date: Wed Nov 11 19:29:10 2009
New Revision: 86920

URL: http://llvm.org/viewvc/llvm-project?rev=86920&view=rev
Log:
expose edge information and switch j-t to use it.

Modified:
    llvm/trunk/include/llvm/Analysis/LazyValueInfo.h
    llvm/trunk/lib/Analysis/LazyValueInfo.cpp
    llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp

Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyValueInfo.h?rev=86920&r1=86919&r2=86920&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyValueInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyValueInfo.h Wed Nov 11 19:29:10 2009
@@ -47,6 +47,10 @@
   /// getConstant - Determine whether the specified value is known to be a
   /// constant at the end of the specified block.  Return null if not.
   Constant *getConstant(Value *V, BasicBlock *BB);
+
+  /// getConstantOnEdge - Determine whether the specified value is known to be a
+  /// constant on the specified edge.  Return null if not.
+  Constant *getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB);
   
   
   // Implementation boilerplate.

Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86920&r1=86919&r2=86920&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Nov 11 19:29:10 2009
@@ -270,6 +270,27 @@
   return 0;
 }
 
+/// getConstantOnEdge - Determine whether the specified value is known to be a
+/// constant on the specified edge.  Return null if not.
+Constant *LazyValueInfo::getConstantOnEdge(Value *V, BasicBlock *FromBB,
+                                           BasicBlock *ToBB) {
+  // If already a constant, return it.
+  if (Constant *VC = dyn_cast<Constant>(V))
+    return VC;
+  
+  DenseMap<BasicBlock*, LVILatticeVal> BlockValues;
+  
+  DEBUG(errs() << "Getting value " << *V << " on edge from '"
+               << FromBB->getName() << "' to '" << ToBB->getName() << "'\n");
+  LVILatticeVal Result = GetValueOnEdge(V, FromBB, ToBB, BlockValues);
+  
+  DEBUG(errs() << "  Result = " << Result << "\n");
+  
+  if (Result.isConstant())
+    return Result.getConstant();
+  return 0;
+}
+
 /// isEqual - Determine whether the specified value is known to be equal or
 /// not-equal to the specified constant at the end of the specified block.
 LazyValueInfo::Tristate

Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86920&r1=86919&r2=86920&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 19:29:10 2009
@@ -278,7 +278,7 @@
       for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
         // If the value is known by LazyValueInfo to be a constant in a
         // predecessor, use that information to try to thread this block.
-        Constant *PredCst = LVI->getConstant(V, *PI);
+        Constant *PredCst = LVI->getConstantOnEdge(V, *PI, BB);
         if (PredCst == 0 ||
             (!isa<ConstantInt>(PredCst) && !isa<UndefValue>(PredCst)))
           continue;
@@ -384,7 +384,7 @@
       for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
         // If the value is known by LazyValueInfo to be a constant in a
         // predecessor, use that information to try to thread this block.
-        Constant *PredCst = LVI->getConstant(Cmp->getOperand(0), *PI);
+        Constant *PredCst = LVI->getConstantOnEdge(Cmp->getOperand(0), *PI, BB);
         if (PredCst == 0)
           continue;
         





More information about the llvm-commits mailing list