aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
diff options
context:
space:
mode:
authorAbinav Puthan Purayil <abinavpp@gmail.com>2022-05-12 22:35:52 +0530
committerAbinav Puthan Purayil <abinavpp@gmail.com>2022-05-16 16:03:30 +0530
commit485dd0b752cd78c93b1c41e922a73c07b565a9f0 (patch)
treee55fe0d9d5e1dfe631b549d85141be3c5712739e /llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
parentf96d20450c00855a842d91d09cbcf765adaf1f17 (diff)
downloadllvm-485dd0b752cd78c93b1c41e922a73c07b565a9f0.zip
llvm-485dd0b752cd78c93b1c41e922a73c07b565a9f0.tar.gz
llvm-485dd0b752cd78c93b1c41e922a73c07b565a9f0.tar.bz2
[GlobalISel] Handle constant splat in funnel shift combine
This change adds the constant splat versions of m_ICst() (by using getBuildVectorConstantSplat()) and uses it in matchOrShiftToFunnelShift(). The getBuildVectorConstantSplat() name is shortened to getIConstantSplatVal() so that the *SExtVal() version would have a more compact name. Differential Revision: https://reviews.llvm.org/D125516
Diffstat (limited to 'llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
index da0aee6..cb8c7b4 100644
--- a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
@@ -51,6 +51,25 @@ TEST_F(AArch64GISelMITest, MatchIntConstantRegister) {
EXPECT_EQ(Src0->VReg, MIBCst.getReg(0));
}
+TEST_F(AArch64GISelMITest, MatchIntConstantSplat) {
+ setUp();
+ if (!TM)
+ return;
+
+ LLT s64 = LLT::scalar(64);
+ LLT v4s64 = LLT::fixed_vector(4, s64);
+
+ MachineInstrBuilder FortyTwoSplat =
+ B.buildSplatVector(v4s64, B.buildConstant(s64, 42));
+ int64_t Cst;
+ EXPECT_TRUE(mi_match(FortyTwoSplat.getReg(0), *MRI, m_ICstOrSplat(Cst)));
+ EXPECT_EQ(Cst, 42);
+
+ MachineInstrBuilder NonConstantSplat =
+ B.buildBuildVector(v4s64, {Copies[0], Copies[0], Copies[0], Copies[0]});
+ EXPECT_FALSE(mi_match(NonConstantSplat.getReg(0), *MRI, m_ICstOrSplat(Cst)));
+}
+
TEST_F(AArch64GISelMITest, MachineInstrPtrBind) {
setUp();
if (!TM)