[llvm] 9e9971b - [PatternMatchTest] Use APInt::getAllOnes() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 06:25:32 PDT 2024
Author: Nikita Popov
Date: 2024-09-05T15:25:05+02:00
New Revision: 9e9971b100e121b83f1de9e9206cddb52cda4815
URL: https://github.com/llvm/llvm-project/commit/9e9971b100e121b83f1de9e9206cddb52cda4815
DIFF: https://github.com/llvm/llvm-project/commit/9e9971b100e121b83f1de9e9206cddb52cda4815.diff
LOG: [PatternMatchTest] Use APInt::getAllOnes() (NFC)
Split out from https://github.com/llvm/llvm-project/pull/80309 to
avoid assertion failures in the future.
Added:
Modified:
llvm/unittests/IR/PatternMatch.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/IR/PatternMatch.cpp b/llvm/unittests/IR/PatternMatch.cpp
index 379f97fb63139f..13f121a2b9c7dd 100644
--- a/llvm/unittests/IR/PatternMatch.cpp
+++ b/llvm/unittests/IR/PatternMatch.cpp
@@ -71,7 +71,7 @@ TEST_F(PatternMatchTest, SpecificIntEQ) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_TRUE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, APInt(BitWidth, 0))
@@ -93,15 +93,15 @@ TEST_F(PatternMatchTest, SpecificIntEQ) {
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));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntNE) {
@@ -110,7 +110,7 @@ TEST_F(PatternMatchTest, SpecificIntNE) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_FALSE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE, APInt(BitWidth, 0))
@@ -132,15 +132,15 @@ TEST_F(PatternMatchTest, SpecificIntNE) {
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));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_NE,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntUGT) {
@@ -149,7 +149,7 @@ TEST_F(PatternMatchTest, SpecificIntUGT) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_FALSE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT, APInt(BitWidth, 0))
@@ -171,15 +171,15 @@ TEST_F(PatternMatchTest, SpecificIntUGT) {
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));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGT,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SignbitZeroChecks) {
@@ -187,7 +187,7 @@ TEST_F(PatternMatchTest, SignbitZeroChecks) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_TRUE(m_Negative().match(NegOne));
EXPECT_FALSE(m_NonNegative().match(NegOne));
@@ -211,7 +211,7 @@ TEST_F(PatternMatchTest, SpecificIntUGE) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_TRUE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE, APInt(BitWidth, 0))
@@ -233,15 +233,15 @@ TEST_F(PatternMatchTest, SpecificIntUGE) {
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));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntULT) {
@@ -250,7 +250,7 @@ TEST_F(PatternMatchTest, SpecificIntULT) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_FALSE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, APInt(BitWidth, 0))
@@ -272,15 +272,15 @@ TEST_F(PatternMatchTest, SpecificIntULT) {
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_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));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntULE) {
@@ -289,7 +289,7 @@ TEST_F(PatternMatchTest, SpecificIntULE) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_TRUE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE, APInt(BitWidth, 0))
@@ -311,15 +311,15 @@ TEST_F(PatternMatchTest, SpecificIntULE) {
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));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULE,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntSGT) {
@@ -328,7 +328,7 @@ TEST_F(PatternMatchTest, SpecificIntSGT) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_FALSE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT, APInt(BitWidth, 0))
@@ -350,15 +350,15 @@ TEST_F(PatternMatchTest, SpecificIntSGT) {
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));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGT,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntSGE) {
@@ -367,7 +367,7 @@ TEST_F(PatternMatchTest, SpecificIntSGE) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_TRUE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE, APInt(BitWidth, 0))
@@ -389,15 +389,15 @@ TEST_F(PatternMatchTest, SpecificIntSGE) {
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));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SGE,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntSLT) {
@@ -406,7 +406,7 @@ TEST_F(PatternMatchTest, SpecificIntSLT) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_FALSE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT, APInt(BitWidth, 0))
@@ -428,15 +428,15 @@ TEST_F(PatternMatchTest, SpecificIntSLT) {
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));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLT,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, SpecificIntSLE) {
@@ -445,7 +445,7 @@ TEST_F(PatternMatchTest, SpecificIntSLE) {
Value *Zero = ConstantInt::get(IntTy, 0);
Value *One = ConstantInt::get(IntTy, 1);
- Value *NegOne = ConstantInt::get(IntTy, -1);
+ Value *NegOne = Constant::getAllOnesValue(IntTy);
EXPECT_TRUE(
m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE, APInt(BitWidth, 0))
@@ -467,15 +467,15 @@ TEST_F(PatternMatchTest, SpecificIntSLE) {
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));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE,
+ APInt::getAllOnes(BitWidth))
+ .match(Zero));
+ EXPECT_FALSE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE,
+ APInt::getAllOnes(BitWidth))
+ .match(One));
+ EXPECT_TRUE(m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_SLE,
+ APInt::getAllOnes(BitWidth))
+ .match(NegOne));
}
TEST_F(PatternMatchTest, Unless) {
More information about the llvm-commits
mailing list