summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-04-30 16:40:30 +0000
committerDan Gohman <gohman@apple.com>2009-04-30 16:40:30 +0000
commit4bafc42185c3e2bf3c65716c51b139cf394d4e7c (patch)
tree6afcf229a64204413cac5d9a3c3594ae7e788c85 /llvm/lib
parent18c435a17da41620411a5fc9c9d66db4b5a7f6a1 (diff)
downloadbcm5719-llvm-4bafc42185c3e2bf3c65716c51b139cf394d4e7c.tar.gz
bcm5719-llvm-4bafc42185c3e2bf3c65716c51b139cf394d4e7c.zip
Don't try to mix integers and pointers in an icmp instruction
in getSCEVAtScope. llvm-svn: 70495
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 5302ea87de8..027ce6ffe15 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -2613,21 +2613,28 @@ SCEVHandle ScalarEvolution::getSCEVAtScope(SCEV *V, const Loop *L) {
// If any of the operands is non-constant and if they are
// non-integer and non-pointer, don't even try to analyze them
// with scev techniques.
- if (!isa<IntegerType>(Op->getType()) &&
- !isa<PointerType>(Op->getType()))
+ if (!isSCEVable(Op->getType()))
return V;
SCEVHandle OpV = getSCEVAtScope(getSCEV(Op), L);
- if (SCEVConstant *SC = dyn_cast<SCEVConstant>(OpV))
- Operands.push_back(ConstantExpr::getIntegerCast(SC->getValue(),
- Op->getType(),
- false));
- else if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(OpV)) {
- if (Constant *C = dyn_cast<Constant>(SU->getValue()))
- Operands.push_back(ConstantExpr::getIntegerCast(C,
- Op->getType(),
- false));
- else
+ if (SCEVConstant *SC = dyn_cast<SCEVConstant>(OpV)) {
+ Constant *C = SC->getValue();
+ if (C->getType() != Op->getType())
+ C = ConstantExpr::getCast(CastInst::getCastOpcode(C, false,
+ Op->getType(),
+ false),
+ C, Op->getType());
+ Operands.push_back(C);
+ } else if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(OpV)) {
+ if (Constant *C = dyn_cast<Constant>(SU->getValue())) {
+ if (C->getType() != Op->getType())
+ C =
+ ConstantExpr::getCast(CastInst::getCastOpcode(C, false,
+ Op->getType(),
+ false),
+ C, Op->getType());
+ Operands.push_back(C);
+ } else
return V;
} else {
return V;
OpenPOWER on IntegriCloud