diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-09-05 23:38:22 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-09-05 23:38:22 +0000 |
commit | eea2ef7862e0be7368a74b142d5d87f700b02a8d (patch) | |
tree | bde070e284bf8815a1d98e324c567c687042ce12 /llvm/lib/Transforms | |
parent | 46f9df5b718891a74067ee59f2e2a1f38dd8e0ed (diff) | |
download | bcm5719-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.cpp | 13 |
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)); |