summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorMichael Zolotukhin <mzolotukhin@apple.com>2014-05-26 14:49:46 +0000
committerMichael Zolotukhin <mzolotukhin@apple.com>2014-05-26 14:49:46 +0000
commit90e79a50bb0d198edb226cccc338fe4333466b5e (patch)
tree5b029de3580df85c97321e424802f98e75478247 /lib/Analysis
parent1322e998c1f00b972120ec7efb1d76a6de2e7956 (diff)
downloadllvm-90e79a50bb0d198edb226cccc338fe4333466b5e.tar.gz
llvm-90e79a50bb0d198edb226cccc338fe4333466b5e.tar.bz2
llvm-90e79a50bb0d198edb226cccc338fe4333466b5e.tar.xz
Some cleanup for r209568.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 461fdac3c6..1087e5df16 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -1208,11 +1208,10 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op,
auto SMul = dyn_cast<SCEVMulExpr>(SA->getOperand(1));
if (SMul && SC1) {
if (auto SC2 = dyn_cast<SCEVConstant>(SMul->getOperand(0))) {
- APInt C1 = SC1->getValue()->getValue();
- APInt C2 = SC2->getValue()->getValue();
- APInt CDiff = C2 - C1;
+ const APInt &C1 = SC1->getValue()->getValue();
+ const APInt &C2 = SC2->getValue()->getValue();
if (C1.isStrictlyPositive() && C2.isStrictlyPositive() &&
- CDiff.isStrictlyPositive() && C2.isPowerOf2())
+ C2.ugt(C1) && C2.isPowerOf2())
return getAddExpr(getSignExtendExpr(SC1, Ty),
getSignExtendExpr(SMul, Ty));
}
@@ -1316,11 +1315,10 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op,
auto SC1 = dyn_cast<SCEVConstant>(Start);
auto SC2 = dyn_cast<SCEVConstant>(Step);
if (SC1 && SC2) {
- APInt C1 = SC1->getValue()->getValue();
- APInt C2 = SC2->getValue()->getValue();
- APInt CDiff = C2 - C1;
- if (C1.isStrictlyPositive() && C2.isStrictlyPositive() &&
- CDiff.isStrictlyPositive() && C2.isPowerOf2()) {
+ const APInt &C1 = SC1->getValue()->getValue();
+ const APInt &C2 = SC2->getValue()->getValue();
+ if (C1.isStrictlyPositive() && C2.isStrictlyPositive() && C2.ugt(C1) &&
+ C2.isPowerOf2()) {
Start = getSignExtendExpr(Start, Ty);
const SCEV *NewAR = getAddRecExpr(getConstant(AR->getType(), 0), Step,
L, AR->getNoWrapFlags());