[llvm-commits] [llvm] r70495 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Transforms/LoopStrengthReduce/pr3086.ll

Dan Gohman gohman at apple.com
Thu Apr 30 09:40:39 PDT 2009


Author: djg
Date: Thu Apr 30 11:40:30 2009
New Revision: 70495

URL: http://llvm.org/viewvc/llvm-project?rev=70495&view=rev
Log:
Don't try to mix integers and pointers in an icmp instruction
in getSCEVAtScope.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
    llvm/trunk/test/Transforms/LoopStrengthReduce/pr3086.ll

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=70495&r1=70494&r2=70495&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Apr 30 11:40:30 2009
@@ -2613,21 +2613,28 @@
             // If any of the operands is non-constant and if they are
             // non-integer and non-pointer, don't even try to analyze them
             // with scev techniques.
-            if (!isa<IntegerType>(Op->getType()) &&
-                !isa<PointerType>(Op->getType()))
+            if (!isSCEVable(Op->getType()))
               return V;
 
             SCEVHandle OpV = getSCEVAtScope(getSCEV(Op), L);
-            if (SCEVConstant *SC = dyn_cast<SCEVConstant>(OpV))
-              Operands.push_back(ConstantExpr::getIntegerCast(SC->getValue(), 
-                                                              Op->getType(), 
-                                                              false));
-            else if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(OpV)) {
-              if (Constant *C = dyn_cast<Constant>(SU->getValue()))
-                Operands.push_back(ConstantExpr::getIntegerCast(C, 
-                                                                Op->getType(), 
-                                                                false));
-              else
+            if (SCEVConstant *SC = dyn_cast<SCEVConstant>(OpV)) {
+              Constant *C = SC->getValue();
+              if (C->getType() != Op->getType())
+                C = ConstantExpr::getCast(CastInst::getCastOpcode(C, false,
+                                                                  Op->getType(),
+                                                                  false),
+                                          C, Op->getType());
+              Operands.push_back(C);
+            } else if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(OpV)) {
+              if (Constant *C = dyn_cast<Constant>(SU->getValue())) {
+                if (C->getType() != Op->getType())
+                  C =
+                    ConstantExpr::getCast(CastInst::getCastOpcode(C, false,
+                                                                  Op->getType(),
+                                                                  false),
+                                          C, Op->getType());
+                Operands.push_back(C);
+              } else
                 return V;
             } else {
               return V;

Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/pr3086.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/pr3086.ll?rev=70495&r1=70494&r2=70495&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/pr3086.ll (original)
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/pr3086.ll Thu Apr 30 11:40:30 2009
@@ -1,4 +1,5 @@
 ; RUN: llvm-as < %s | opt -loop-reduce -disable-output
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output
 ; PR 3086
 
 	%struct.Cls = type { i32, i8, [2 x %struct.Cls*], [2 x %struct.Lit*] }





More information about the llvm-commits mailing list