Revert this use of NUW/NSW also. Overflow-undefined multiplication isn't
authorDan Gohman <gohman@apple.com>
Fri, 18 Dec 2009 18:45:31 +0000 (18:45 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 18 Dec 2009 18:45:31 +0000 (18:45 +0000)
associative either.

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

lib/Analysis/ScalarEvolution.cpp

index 3c937e05cc52a6e49b49295c6300ce604872a29a..ec901b77ccc2c6ee08ab425fa4a502332228b867 100644 (file)
@@ -1460,7 +1460,10 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
                                              AddRec->op_end());
       AddRecOps[0] = getAddExpr(LIOps);
 
+      // It's tempting to propogate NUW/NSW flags here, but nuw/nsw addition
+      // is not associative so this isn't necessarily safe.
       const SCEV *NewRec = getAddRecExpr(AddRecOps, AddRec->getLoop());
+
       // If all of the other operands were loop invariant, we are done.
       if (Ops.size() == 1) return NewRec;
 
@@ -1636,9 +1639,9 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
         }
       }
 
-      const SCEV *NewRec = getAddRecExpr(NewOps, AddRec->getLoop(),
-                                         AddRec->hasNoUnsignedWrap() && HasNUW,
-                                         AddRec->hasNoSignedWrap() && HasNSW);
+      // It's tempting to propogate NUW/NSW flags here, but nuw/nsw multiplication
+      // is not associative so this isn't necessarily safe.
+      const SCEV *NewRec = getAddRecExpr(NewOps, AddRec->getLoop());
 
       // If all of the other operands were loop invariant, we are done.
       if (Ops.size() == 1) return NewRec;