From: Sebastian Pop Date: Tue, 8 Apr 2014 21:21:10 +0000 (+0000) Subject: handle special cases when findGCD returns 1 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=89e11b110afa9af4bae5392791022b466ca96a5e;p=oota-llvm.git handle special cases when findGCD returns 1 used to fail with 'Step should divide Start with no remainder.' git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205801 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index d6165111dba..6ccf8aac3b8 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -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; }