[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp SCCP.cpp

Reid Spencer reid at x10sys.com
Mon Dec 11 21:05:25 PST 2006



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.98 -> 1.99
SCCP.cpp updated: 1.140 -> 1.141
---
Log message:

Change inferred getCast into specific getCast. Passes all tests.


---
Diffs of the changes:  (+9 -3)

 LoopStrengthReduce.cpp |    9 +++++++--
 SCCP.cpp               |    3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.98 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.99
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.98	Wed Dec  6 19:30:31 2006
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Mon Dec 11 23:04:59 2006
@@ -200,12 +200,17 @@
   return new LoopStrengthReduce(TLI);
 }
 
-/// getCastedVersionOf - Return the specified value casted to uintptr_t.
+/// getCastedVersionOf - Return the specified value casted to uintptr_t. This
+/// assumes that the Value* V is of integer or pointer type only.
 ///
 Value *LoopStrengthReduce::getCastedVersionOf(Value *V) {
   if (V->getType() == UIntPtrTy) return V;
   if (Constant *CB = dyn_cast<Constant>(V))
-    return ConstantExpr::getCast(CB, UIntPtrTy);
+    if (CB->getType()->isInteger())
+      return ConstantExpr::getIntegerCast(CB, UIntPtrTy, 
+                                          CB->getType()->isSigned());
+    else
+      return ConstantExpr::getPtrToInt(CB, UIntPtrTy);
 
   Value *&New = CastedPointers[V];
   if (New) return New;


Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.140 llvm/lib/Transforms/Scalar/SCCP.cpp:1.141
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.140	Wed Dec  6 19:30:31 2006
+++ llvm/lib/Transforms/Scalar/SCCP.cpp	Mon Dec 11 23:04:59 2006
@@ -589,7 +589,8 @@
   if (VState.isOverdefined())          // Inherit overdefinedness of operand
     markOverdefined(&I);
   else if (VState.isConstant())        // Propagate constant value
-    markConstant(&I, ConstantExpr::getCast(VState.getConstant(), I.getType()));
+    markConstant(&I, ConstantExpr::getCast(I.getOpcode(), 
+                                           VState.getConstant(), I.getType()));
 }
 
 void SCCPSolver::visitSelectInst(SelectInst &I) {






More information about the llvm-commits mailing list