summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-09-05 23:38:22 +0000
committerSanjay Patel <spatel@rotateright.com>2016-09-05 23:38:22 +0000
commiteea2ef7862e0be7368a74b142d5d87f700b02a8d (patch)
treebde070e284bf8815a1d98e324c567c687042ce12 /llvm/lib/Transforms
parent46f9df5b718891a74067ee59f2e2a1f38dd8e0ed (diff)
downloadbcm5719-llvm-eea2ef7862e0be7368a74b142d5d87f700b02a8d.tar.gz
bcm5719-llvm-eea2ef7862e0be7368a74b142d5d87f700b02a8d.zip
[InstCombine] don't assert that division-by-constant has been folded (PR30281)
This is effectively a revert of: https://reviews.llvm.org/rL280115 And this should fix https://llvm.org/bugs/show_bug.cgi?id=30281: llvm-svn: 280677
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index ad2bd1841f1..fc90c4a40a8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1976,13 +1976,12 @@ Instruction *InstCombiner::foldICmpDivConstant(ICmpInst &Cmp,
if (!Cmp.isEquality() && DivIsSigned != Cmp.isSigned())
return nullptr;
- // These constant divides should already be folded in InstSimplify.
- assert(*C2 != 0 && "The ProdOV computation fails on divide by zero.");
- assert(*C2 != 1 && "Funny cases with INT_MIN will fail.");
-
- // This constant divide should already be folded in InstCombine.
- assert(!(DivIsSigned && C2->isAllOnesValue()) &&
- "The overflow computation will fail.");
+ // The ProdOV computation fails on divide by 0 and divide by -1. Cases with
+ // INT_MIN will also fail if the divisor is 1. Although folds of all these
+ // division-by-constant cases should be present, we can not assert that they
+ // have happened before we reach this icmp instruction.
+ if (*C2 == 0 || *C2 == 1 || (DivIsSigned && C2->isAllOnesValue()))
+ return nullptr;
// TODO: We could do all of the computations below using APInt.
Constant *CmpRHS = cast<Constant>(Cmp.getOperand(1));
OpenPOWER on IntegriCloud