summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-03-26 20:28:37 +0000
committerAndrew Trick <atrick@apple.com>2012-03-26 20:28:37 +0000
commit05fecbe42e835b30274a7b38af27687a8abbd114 (patch)
tree8ef687baa95e9b2e78812374aef7778d17eb2850 /lib/Transforms/Scalar/LoopStrengthReduce.cpp
parentd4e46a6316c8e1dc4623ead64b4cdd3dfb103180 (diff)
downloadllvm-05fecbe42e835b30274a7b38af27687a8abbd114.tar.gz
llvm-05fecbe42e835b30274a7b38af27687a8abbd114.tar.bz2
llvm-05fecbe42e835b30274a7b38af27687a8abbd114.tar.xz
LSR ivchain bug fix: corner case with ConstantExpr.
Fixes PR11950. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153463 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index f2112446ad..7e71683dc1 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -704,8 +704,9 @@ static bool isHighCostExpansion(const SCEV *S,
Value *UVal = U->getValue();
for (Value::use_iterator UI = UVal->use_begin(), UE = UVal->use_end();
UI != UE; ++UI) {
- Instruction *User = cast<Instruction>(*UI);
- if (User->getOpcode() == Instruction::Mul
+ // If U is a constant, it may be used by a ConstantExpr.
+ Instruction *User = dyn_cast<Instruction>(*UI);
+ if (User && User->getOpcode() == Instruction::Mul
&& SE.isSCEVable(User->getType())) {
return SE.getSCEV(User) == Mul;
}