From: Roman Lebedev Date: Wed, 10 Jul 2019 16:07:35 +0000 (+0000) Subject: [PatternMatch] Generalize m_SpecificInt_ULT() to take ICmpInst::Predicate X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e90a51722f826d1b67bb2bd70f567e4fe96df4a5;p=llvm [PatternMatch] Generalize m_SpecificInt_ULT() to take ICmpInst::Predicate As discussed in the original review, this may be useful, so let's just do it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365652 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/PatternMatch.h b/include/llvm/IR/PatternMatch.h index 1a11af27d1a..0f03d7cc56b 100644 --- a/include/llvm/IR/PatternMatch.h +++ b/include/llvm/IR/PatternMatch.h @@ -418,16 +418,42 @@ inline cst_pred_ty m_LowBitMask() { return cst_pred_ty(); } -struct is_unsigned_less_than { +struct icmp_pred_with_threshold { + ICmpInst::Predicate Pred; const APInt *Thr; - bool isValue(const APInt &C) { return C.ult(*Thr); } -}; -/// Match an integer or vector with every element unsigned less than the -/// Threshold. For vectors, this includes constants with undefined elements. -/// FIXME: is it worth generalizing this to simply take ICmpInst::Predicate? -inline cst_pred_ty -m_SpecificInt_ULT(const APInt &Threshold) { - cst_pred_ty P; + bool isValue(const APInt &C) { + switch (Pred) { + case ICmpInst::Predicate::ICMP_EQ: + return C.eq(*Thr); + case ICmpInst::Predicate::ICMP_NE: + return C.ne(*Thr); + case ICmpInst::Predicate::ICMP_UGT: + return C.ugt(*Thr); + case ICmpInst::Predicate::ICMP_UGE: + return C.uge(*Thr); + case ICmpInst::Predicate::ICMP_ULT: + return C.ult(*Thr); + case ICmpInst::Predicate::ICMP_ULE: + return C.ule(*Thr); + case ICmpInst::Predicate::ICMP_SGT: + return C.sgt(*Thr); + case ICmpInst::Predicate::ICMP_SGE: + return C.sge(*Thr); + case ICmpInst::Predicate::ICMP_SLT: + return C.slt(*Thr); + case ICmpInst::Predicate::ICMP_SLE: + return C.sle(*Thr); + default: + llvm_unreachable("Unhandled ICmp predicate"); + } + } +}; +/// Match an integer or vector with every element comparing 'pred' (eg/ne/...) +/// to Threshold. For vectors, this includes constants with undefined elements. +inline cst_pred_ty +m_SpecificInt_ICMP(ICmpInst::Predicate Predicate, const APInt &Threshold) { + cst_pred_ty P; + P.Pred = Predicate; P.Thr = &Threshold; return P; } diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index 4c818193ced..3a4283ae540 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3316,7 +3316,8 @@ foldShiftIntoShiftInAnotherHandOfAndInICmp(ICmpInst &I, const SimplifyQuery SQ, // Is the new shift amount smaller than the bit width? // FIXME: could also rely on ConstantRange. unsigned BitWidth = X->getType()->getScalarSizeInBits(); - if (!match(NewShAmt, m_SpecificInt_ULT(APInt(BitWidth, BitWidth)))) + if (!match(NewShAmt, m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, + APInt(BitWidth, BitWidth)))) return nullptr; // All good, we can do this fold. The shift is the same that was for X. Value *T0 = XShiftOpcode == Instruction::BinaryOps::LShr diff --git a/lib/Transforms/InstCombine/InstCombineShifts.cpp b/lib/Transforms/InstCombine/InstCombineShifts.cpp index 0bbecde2184..c821292400c 100644 --- a/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -48,7 +48,8 @@ reassociateShiftAmtsOfTwoSameDirectionShifts(BinaryOperator *Sh0, // Is the new shift amount smaller than the bit width? // FIXME: could also rely on ConstantRange. unsigned BitWidth = X->getType()->getScalarSizeInBits(); - if (!match(NewShAmt, m_SpecificInt_ULT(APInt(BitWidth, BitWidth)))) + if (!match(NewShAmt, m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, + APInt(BitWidth, BitWidth)))) return nullptr; // All good, we can do this fold. BinaryOperator *NewShift = BinaryOperator::Create(ShiftOpcode, X, NewShAmt); diff --git a/unittests/IR/PatternMatch.cpp b/unittests/IR/PatternMatch.cpp index 8ea7a68b27c..600494fba26 100644 --- a/unittests/IR/PatternMatch.cpp +++ b/unittests/IR/PatternMatch.cpp @@ -64,6 +64,162 @@ TEST_F(PatternMatchTest, OneUse) { EXPECT_FALSE(m_OneUse(m_Value()).match(Leaf)); } +TEST_F(PatternMatchTest, SpecificIntEQ) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, 0)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, 1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, -1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntNE) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, 0)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, 1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, -1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntUGT) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, 0)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, 1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, -1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntUGE) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, 0)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, 1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, -1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, -1)) + .match(NegOne)); +} + TEST_F(PatternMatchTest, SpecificIntULT) { Type *IntTy = IRB.getInt32Ty(); unsigned BitWidth = IntTy->getScalarSizeInBits(); @@ -72,17 +228,230 @@ TEST_F(PatternMatchTest, SpecificIntULT) { Value *One = ConstantInt::get(IntTy, 1); Value *NegOne = ConstantInt::get(IntTy, -1); - EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 0)).match(Zero)); - EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 0)).match(One)); - EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 0)).match(NegOne)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, 0)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, 0)) + .match(NegOne)); - EXPECT_TRUE(m_SpecificInt_ULT(APInt(BitWidth, 1)).match(Zero)); - EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 1)).match(One)); - EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 1)).match(NegOne)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, 1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, 1)) + .match(NegOne)); - EXPECT_TRUE(m_SpecificInt_ULT(APInt(BitWidth, -1)).match(Zero)); - EXPECT_TRUE(m_SpecificInt_ULT(APInt(BitWidth, -1)).match(One)); - EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, -1)).match(NegOne)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, -1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntULE) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, 0)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, 1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, -1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntSGT) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, 0)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, 1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, -1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntSGE) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, 0)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, 1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, -1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntSLT) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, 0)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, 1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, -1)) + .match(One)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, -1)) + .match(NegOne)); +} + +TEST_F(PatternMatchTest, SpecificIntSLE) { + Type *IntTy = IRB.getInt32Ty(); + unsigned BitWidth = IntTy->getScalarSizeInBits(); + + Value *Zero = ConstantInt::get(IntTy, 0); + Value *One = ConstantInt::get(IntTy, 1); + Value *NegOne = ConstantInt::get(IntTy, -1); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, 0)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, 0)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, 0)) + .match(NegOne)); + + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, 1)) + .match(Zero)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, 1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, 1)) + .match(NegOne)); + + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, -1)) + .match(Zero)); + EXPECT_FALSE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, -1)) + .match(One)); + EXPECT_TRUE( + m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, -1)) + .match(NegOne)); } TEST_F(PatternMatchTest, CommutativeDeferredValue) {