From 89e11b110afa9af4bae5392791022b466ca96a5e Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Tue, 8 Apr 2014 21:21:10 +0000 Subject: [PATCH] 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 --- lib/Analysis/ScalarEvolution.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } -- 2.34.1