[llvm] r205801 - handle special cases when findGCD returns 1

Sebastian Pop spop at codeaurora.org
Tue Apr 8 14:21:10 PDT 2014


Author: spop
Date: Tue Apr  8 16:21:10 2014
New Revision: 205801

URL: http://llvm.org/viewvc/llvm-project?rev=205801&view=rev
Log:
handle special cases when findGCD returns 1

used to fail with 'Step should divide Start with no remainder.'

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=205801&r1=205800&r2=205801&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Apr  8 16:21:10 2014
@@ -7001,12 +7001,17 @@ public:
 
     const SCEV *Rem = Zero;
     const SCEV *Res = findGCD(SE, Expr->getOperand(0), GCD, &Rem);
+    if (Res == One || Res->isAllOnesValue()) {
+      Remainder = Expr;
+      return GCD;
+    }
+
     if (Rem != Zero)
       Remainder = SE.getAddExpr(Remainder, Rem);
 
     Rem = Zero;
     Res = findGCD(SE, Expr->getOperand(1), Res, &Rem);
-    if (Rem != Zero) {
+    if (Rem != Zero || Res == One || Res->isAllOnesValue()) {
       Remainder = Expr;
       return GCD;
     }





More information about the llvm-commits mailing list