summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-11-17 23:36:35 +0000
committerAndrew Trick <atrick@apple.com>2011-11-17 23:36:35 +0000
commit949045864d36579033ddd57a4aac4db3f4ce87bd (patch)
tree7aa07ace0b9e4339520a4f6df69f43c03041fe3d /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parent651982790a0ec3a9e1f88b2e0d6231e5d62befc7 (diff)
downloadbcm5719-llvm-949045864d36579033ddd57a4aac4db3f4ce87bd.tar.gz
bcm5719-llvm-949045864d36579033ddd57a4aac4db3f4ce87bd.zip
Fix an overly general check in SimplifyIndvar to handle useless phi cycles.
The right way to check for a binary operation is cast<BinaryOperator>. The original check: cast<Instruction> && numOperands() == 2 would match phi "instructions", leading to an infinite loop in extreme corner case: a useless phi with operands [self, constant] that prior optimization passes failed to remove, being used in the loop by another useless phi, in turn being used by an lshr or udiv. Fixes PR11350: runaway iteration assertion. llvm-svn: 144935
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 76289c055b9..6732a789d5f 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -107,8 +107,8 @@ Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand)
// Attempt to fold a binary operator with constant operand.
// e.g. ((I + 1) >> 2) => I >> 2
- if (IVOperand->getNumOperands() != 2 ||
- !isa<ConstantInt>(IVOperand->getOperand(1)))
+ if (!isa<BinaryOperator>(IVOperand)
+ || !isa<ConstantInt>(IVOperand->getOperand(1)))
return 0;
IVSrc = IVOperand->getOperand(0);
OpenPOWER on IntegriCloud