Skip to content

Commit

Permalink
Revert "[InstCombine][NFC] Factor out constant check"
Browse files Browse the repository at this point in the history
This reverts commit 9bdb918.

This refactoring proved to not be useful.
  • Loading branch information
xortator committed Jun 5, 2020
1 parent 929edd8 commit 80cb25c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 80cb25c

Please sign in to comment.