summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-04-08 23:36:27 +0000
committerDan Gohman <gohman@apple.com>2010-04-08 23:36:27 +0000
commite60bb15982dc40517e078c3858fdc0716d43abb5 (patch)
tree38b72394f7f363b0bf08bc23714087a942ded4fd /lib
parentdd98c4d1859a318e7586f87031db44b215476020 (diff)
downloadllvm-e60bb15982dc40517e078c3858fdc0716d43abb5.tar.gz
llvm-e60bb15982dc40517e078c3858fdc0716d43abb5.tar.bz2
llvm-e60bb15982dc40517e078c3858fdc0716d43abb5.tar.xz
Avoid allocating a value of zero in a register if the initial formula
inputs happen to negate each other. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100828 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index e50b13d63d..4669b60e8d 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -262,11 +262,15 @@ void Formula::InitialMatch(const SCEV *S, Loop *L,
SmallVector<const SCEV *, 4> Bad;
DoInitialMatch(S, L, Good, Bad, SE, DT);
if (!Good.empty()) {
- BaseRegs.push_back(SE.getAddExpr(Good));
+ const SCEV *Sum = SE.getAddExpr(Good);
+ if (!Sum->isZero())
+ BaseRegs.push_back(Sum);
AM.HasBaseReg = true;
}
if (!Bad.empty()) {
- BaseRegs.push_back(SE.getAddExpr(Bad));
+ const SCEV *Sum = SE.getAddExpr(Bad);
+ if (!Sum->isZero())
+ BaseRegs.push_back(Sum);
AM.HasBaseReg = true;
}
}