In SCEVAddExpr::get, skip over any cast operands before looking for nested
authorDan Gohman <gohman@apple.com>
Mon, 18 Jun 2007 19:30:09 +0000 (19:30 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 18 Jun 2007 19:30:09 +0000 (19:30 +0000)
add operands after constant operands. The recent change to recognize
sign-extend expressions caused this to be exposed more often.

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

lib/Analysis/ScalarEvolution.cpp

index 3ae65286fa731547faf1862e7b637e21d4a3e6d8..ed8ea32767872f70d8d477ad14ebb00c3daa31ec 100644 (file)
@@ -685,8 +685,11 @@ SCEVHandle SCEVAddExpr::get(std::vector<SCEVHandle> &Ops) {
       return SCEVAddExpr::get(Ops);
     }
 
-  // Okay, now we know the first non-constant operand.  If there are add
-  // operands they would be next.
+  // Now we know the first non-constant operand.  Skip past any cast SCEVs.
+  while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scAddExpr)
+    ++Idx;
+
+  // If there are add operands they would be next.
   if (Idx < Ops.size()) {
     bool DeletedAdd = false;
     while (SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[Idx])) {