diff options
author | Dan Gohman <gohman@apple.com> | 2009-04-30 16:40:30 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-04-30 16:40:30 +0000 |
commit | 4acd12a0cbe6d1e478e13feefbc67c654e552e68 (patch) | |
tree | bf2229edf41e522063501000846afd828137f43e | |
parent | 1d621f71c84c4f4d0574c0fa17fc5a8f6c49b46f (diff) |
Don't try to mix integers and pointers in an icmp instruction
in getSCEVAtScope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70495 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 31 | ||||
-rw-r--r-- | test/Transforms/LoopStrengthReduce/pr3086.ll | 1 |
2 files changed, 20 insertions, 12 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 5302ea87de..027ce6ffe1 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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; diff --git a/test/Transforms/LoopStrengthReduce/pr3086.ll b/test/Transforms/LoopStrengthReduce/pr3086.ll index 4ca333f614..f92bfe2b68 100644 --- a/test/Transforms/LoopStrengthReduce/pr3086.ll +++ b/test/Transforms/LoopStrengthReduce/pr3086.ll @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | opt -loop-reduce -disable-output +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output ; PR 3086 %struct.Cls = type { i32, i8, [2 x %struct.Cls*], [2 x %struct.Lit*] } |