When complicated expressions are broken down into subexpressions

with multiplication by constants distributed through, occasionally
those subexpressions can include both x and -x. For now, if this
condition is discovered within LSR, just prune such cases away,
as they won't be profitable. This fixes a "zero allocated in a
base register" assertion failure.

llvm-svn: 96177
This commit is contained in:
Dan Gohman 2010-02-14 18:50:49 +00:00
parent d0413848cc
commit bb7d52213c
1 changed files with 8 additions and 2 deletions

View File

@ -2012,8 +2012,14 @@ void LSRInstance::GenerateCombinations(LSRUse &LU, unsigned LUIdx,
F.BaseRegs.push_back(BaseReg); F.BaseRegs.push_back(BaseReg);
} }
if (Ops.size() > 1) { if (Ops.size() > 1) {
F.BaseRegs.push_back(SE.getAddExpr(Ops)); const SCEV *Sum = SE.getAddExpr(Ops);
(void)InsertFormula(LU, LUIdx, F); // TODO: If Sum is zero, it probably means ScalarEvolution missed an
// opportunity to fold something. For now, just ignore such cases
// rather than procede with zero in a register.
if (!Sum->isZero()) {
F.BaseRegs.push_back(Sum);
(void)InsertFormula(LU, LUIdx, F);
}
} }
} }