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
This commit is contained in:
Sebastian Pop 2014-04-08 21:21:10 +00:00
parent d541e6e6ea
commit 89e11b110a

View File

@ -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;
}