diff options
author | Max Kazantsev <mkazantsev@azul.com> | 2020-06-05 12:00:44 +0700 |
---|---|---|
committer | Max Kazantsev <mkazantsev@azul.com> | 2020-06-05 12:00:44 +0700 |
commit | 80cb25cbd555f9634836b766c86aead435b60eaa (patch) | |
tree | 11318c4e8e7544af0076e61acdd1ebc0b1557f8f | |
parent | 929edd8bd25b0390de97994eb90f42b26636d205 (diff) | |
download | llvm-80cb25cbd555f9634836b766c86aead435b60eaa.zip llvm-80cb25cbd555f9634836b766c86aead435b60eaa.tar.gz llvm-80cb25cbd555f9634836b766c86aead435b60eaa.tar.bz2 |
Revert "[InstCombine][NFC] Factor out constant check"
This reverts commit 9bdb91889020b3e61cba26adb1b9c64a24c09f95.
This refactoring proved to not be useful.
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index e7371d2..48375a1 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1432,13 +1432,6 @@ Instruction *InstCombiner::foldICmpWithZero(ICmpInst &Cmp) { /// possible that code has been made unnecessary - do we canonicalize IR to /// overflow/saturating intrinsics or not?). Instruction *InstCombiner::foldICmpWithConstant(ICmpInst &Cmp) { - Value *Op0 = Cmp.getOperand(0), *Op1 = Cmp.getOperand(1); - ConstantInt *CI; - - // Make sure that the RHS operand is a constant. - if (!match(Op1, m_ConstantInt(CI))) - return nullptr; - // Match the following pattern, which is a common idiom when writing // overflow-safe integer arithmetic functions. The source performs an addition // in wider type and explicitly checks for overflow using comparisons against @@ -1451,9 +1444,10 @@ Instruction *InstCombiner::foldICmpWithConstant(ICmpInst &Cmp) { // sum = a + b // if (sum+128 >u 255) ... -> llvm.sadd.with.overflow.i8 CmpInst::Predicate Pred = Cmp.getPredicate(); + Value *Op0 = Cmp.getOperand(0), *Op1 = Cmp.getOperand(1); Value *A, *B; - ConstantInt *CI2; // I = icmp ugt (add (add A, B), CI2), CI - if (Pred == ICmpInst::ICMP_UGT && + ConstantInt *CI, *CI2; // I = icmp ugt (add (add A, B), CI2), CI + if (Pred == ICmpInst::ICMP_UGT && match(Op1, m_ConstantInt(CI)) && match(Op0, m_Add(m_Add(m_Value(A), m_Value(B)), m_ConstantInt(CI2)))) if (Instruction *Res = processUGT_ADDCST_ADD(Cmp, A, B, CI2, CI, *this)) return Res; |