diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-14 18:50:49 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-14 18:50:49 +0000 |
commit | ce947366ec07ed3e9b017f0f4a07fa668a799119 (patch) | |
tree | 71f28ad57916ef92bac7c6d05648627482181163 | |
parent | 44de6823fc36eb7151b4a3077db9b10ec8f14442 (diff) | |
download | external_llvm-ce947366ec07ed3e9b017f0f4a07fa668a799119.zip external_llvm-ce947366ec07ed3e9b017f0f4a07fa668a799119.tar.gz external_llvm-ce947366ec07ed3e9b017f0f4a07fa668a799119.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96177 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index b6ef718..11f2187 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2012,8 +2012,14 @@ void LSRInstance::GenerateCombinations(LSRUse &LU, unsigned LUIdx, F.BaseRegs.push_back(BaseReg); } if (Ops.size() > 1) { - F.BaseRegs.push_back(SE.getAddExpr(Ops)); - (void)InsertFormula(LU, LUIdx, F); + const SCEV *Sum = SE.getAddExpr(Ops); + // 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); + } } } |