[llvm] b038912 - [PatternMatch] add tests for constant expression matcher; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 12:24:06 PDT 2022
Author: Sanjay Patel
Date: 2022-07-21T15:23:57-04:00
New Revision: b03891268cc378ce01a8da40483224aa1cfee5b6
URL: https://github.com/llvm/llvm-project/commit/b03891268cc378ce01a8da40483224aa1cfee5b6
DIFF: https://github.com/llvm/llvm-project/commit/b03891268cc378ce01a8da40483224aa1cfee5b6.diff
LOG: [PatternMatch] add tests for constant expression matcher; NFC
Added:
Modified:
llvm/unittests/IR/PatternMatch.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/IR/PatternMatch.cpp b/llvm/unittests/IR/PatternMatch.cpp
index a95e2df1eb2c..9314e6799b8f 100644
--- a/llvm/unittests/IR/PatternMatch.cpp
+++ b/llvm/unittests/IR/PatternMatch.cpp
@@ -1790,4 +1790,16 @@ TYPED_TEST(MutableConstTest, ICmp) {
EXPECT_EQ(R, MatchR);
}
+TEST_F(PatternMatchTest, ConstExpr) {
+ Constant *G =
+ M->getOrInsertGlobal("dummy", PointerType::getUnqual(IRB.getInt32Ty()));
+ Constant *S = ConstantExpr::getPtrToInt(G, IRB.getInt32Ty());
+ Type *VecTy = FixedVectorType::get(IRB.getInt32Ty(), 2);
+ PoisonValue *P = PoisonValue::get(VecTy);
+ Constant *V = ConstantExpr::getInsertElement(P, S, IRB.getInt32(0));
+
+ EXPECT_TRUE(match(S, m_ConstantExpr()));
+ EXPECT_FALSE(match(V, m_ConstantExpr()));
+}
+
} // anonymous namespace.
More information about the llvm-commits
mailing list