summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-05-27 21:10:47 +0000
committerDan Gohman <gohman@apple.com>2009-05-27 21:10:47 +0000
commit4d1823680d41578e398cc08b017faaca1f923e5d (patch)
tree508730796d0cf2ddb201c22f46916d29e204d4cf /llvm/lib/Transforms
parenta56159b7e99d7991cd2acd69d730ec21bcbcaaec (diff)
downloadbcm5719-llvm-4d1823680d41578e398cc08b017faaca1f923e5d.tar.gz
bcm5719-llvm-4d1823680d41578e398cc08b017faaca1f923e5d.zip
Revert 72493 and replace it with a more conservative fix, for now: don't
rewrite the comparison if there is any implicit extension or truncation on the induction variable. I'm planning for IVUsers to eventually take over some of the work of this code, and for it to be generalized. llvm-svn: 72496
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 834a95d7318..92270b5b647 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1993,6 +1993,12 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
ValidScale(!CommonExprs->isZero(), Scale, UsersToProcess))
continue;
+ // Avoid rewriting the compare instruction with an iv which has
+ // implicit extension or truncation built into it.
+ // TODO: This is over-conservative.
+ if (SE->getTypeSizeInBits(CondUse->getOffset()->getType()) != TyBits)
+ continue;
+
// If scale is negative, use swapped predicate unless it's testing
// for equality.
if (Scale < 0 && !Cond->isEquality())
@@ -2005,16 +2011,11 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
ConstantInt *CI = ConstantInt::get(NewCmpIntTy, NewCmpVal);
NewCmpRHS = ConstantExpr::getIntToPtr(CI, NewCmpTy);
}
- NewOffset = CondUse->getOffset();
- if (CondUse->isSigned())
- NewOffset = SE->getNoopOrSignExtend(CondUse->getOffset(), NewCmpTy);
- else
- NewOffset = SE->getNoopOrZeroExtend(CondUse->getOffset(), NewCmpTy);
NewOffset = TyBits == NewTyBits
- ? SE->getMulExpr(NewOffset,
+ ? SE->getMulExpr(CondUse->getOffset(),
SE->getConstant(ConstantInt::get(CmpTy, Scale)))
: SE->getConstant(ConstantInt::get(NewCmpIntTy,
- cast<SCEVConstant>(NewOffset)->getValue()
+ cast<SCEVConstant>(CondUse->getOffset())->getValue()
->getSExtValue()*Scale));
break;
}
OpenPOWER on IntegriCloud