summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-04-02 18:50:58 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-04-02 18:50:58 +0000
commit50a281a871ee64ad76c6c44f4b60b8d47f88f4c3 (patch)
tree2bdb208e12d06b63d708679879c5f1bbd6ee6bba /llvm/lib/Transforms
parent1473c9a7c484590a842120c0517974ca1d3584b3 (diff)
downloadbcm5719-llvm-50a281a871ee64ad76c6c44f4b60b8d47f88f4c3.tar.gz
bcm5719-llvm-50a281a871ee64ad76c6c44f4b60b8d47f88f4c3.zip
While SimplifyDemandedBits constant folds this, we can't rely on it here.
It's possible to craft an input that hits the recursion limits in a way that SimplifyDemandedBits doesn't simplify the icmp but ComputeMaskedBits can infer which bits are zero. No test case as it depends on too many other things. Fixes PR9609. llvm-svn: 128777
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 32ab123f103..6f70de86576 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -913,8 +913,13 @@ Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
if (KnownZeroMask.isPowerOf2()) {
Value *In = ICI->getOperand(0);
- assert((Op1C->isZero() || Op1C->getValue() == KnownZeroMask) &&
- "Constant icmp not folded?");
+ // If the icmp tests for a known zero bit we can constant fold it.
+ if (!Op1C->isZero() && Op1C->getValue() != KnownZeroMask) {
+ Value *V = Pred == ICmpInst::ICMP_NE ?
+ ConstantInt::getAllOnesValue(CI.getType()) :
+ ConstantInt::getNullValue(CI.getType());
+ return ReplaceInstUsesWith(CI, V);
+ }
if (!Op1C->isZero() == (Pred == ICmpInst::ICMP_NE)) {
// sext ((x & 2^n) == 0) -> (x >> n) - 1
OpenPOWER on IntegriCloud