Skip to content

Commit f1a7cc9

Browse files
committed
All revisions
1 parent 24329cf commit f1a7cc9

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

llvm/include/llvm/CodeGen/SDPatternMatch.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ m_InsertElt(const T0_P &Vec, const T1_P &Val, const T2_P &Idx) {
516516

517517
template <typename LHS, typename RHS, typename IDX>
518518
inline TernaryOpc_match<LHS, RHS, IDX>
519-
m_InsertSubvector(const LHS &L, const RHS &R, const IDX &I) {
520-
return TernaryOpc_match<LHS, RHS, IDX>(ISD::INSERT_SUBVECTOR, L, R, I);
519+
m_InsertSubvector(const LHS &Base, const RHS &Sub, const IDX &Idx) {
520+
return TernaryOpc_match<LHS, RHS, IDX>(ISD::INSERT_SUBVECTOR, Base, Sub, Idx);
521521
}
522522

523523
// === Binary operations ===
@@ -809,9 +809,9 @@ inline BinaryOpc_match<LHS, RHS> m_ExtractElt(const LHS &Vec, const RHS &Idx) {
809809
}
810810

811811
template <typename LHS, typename RHS>
812-
inline BinaryOpc_match<LHS, RHS> m_ExtractSubvector(const LHS &L,
813-
const RHS &R) {
814-
return BinaryOpc_match<LHS, RHS>(ISD::EXTRACT_SUBVECTOR, L, R);
812+
inline BinaryOpc_match<LHS, RHS> m_ExtractSubvector(const LHS &Vec,
813+
const RHS &Idx) {
814+
return BinaryOpc_match<LHS, RHS>(ISD::EXTRACT_SUBVECTOR, Vec, Idx);
815815
}
816816

817817
// === Unary operations ===

llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ TEST_F(SelectionDAGPatternMatchTest, matchTernaryOp) {
140140
auto VInt32VT = EVT::getVectorVT(Context, Int32VT, 4);
141141
auto SmallVInt32VT = EVT::getVectorVT(Context, Int32VT, 2);
142142
auto Idx0 = DAG->getVectorIdxConstant(0, DL);
143+
auto Idx3 = DAG->getVectorIdxConstant(3, DL);
143144
SDValue V1 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 6, VInt32VT);
144145
SDValue V2 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 7, VInt32VT);
145146
SDValue V3 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 8, SmallVInt32VT);
@@ -193,6 +194,16 @@ TEST_F(SelectionDAGPatternMatchTest, matchTernaryOp) {
193194
EXPECT_TRUE(sd_match(
194195
InsertSubvector,
195196
m_InsertSubvector(m_Specific(V2), m_Specific(V3), m_Specific(Idx0))));
197+
EXPECT_TRUE(sd_match(
198+
InsertSubvector,
199+
m_InsertSubvector(m_Specific(V2), m_Specific(V3), m_SpecificInt(0))));
200+
EXPECT_FALSE(sd_match(
201+
InsertSubvector,
202+
m_InsertSubvector(m_Specific(V2), m_Specific(V3), m_Specific(Idx3))));
203+
EXPECT_FALSE(sd_match(
204+
InsertSubvector,
205+
m_InsertSubvector(m_Specific(V2), m_Specific(V3), m_SpecificInt(3))));
206+
196207
}
197208

198209
TEST_F(SelectionDAGPatternMatchTest, matchBinaryOp) {
@@ -204,6 +215,7 @@ TEST_F(SelectionDAGPatternMatchTest, matchBinaryOp) {
204215

205216
SDValue V1 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 6, VInt32VT);
206217
auto Idx0 = DAG->getVectorIdxConstant(0, DL);
218+
auto Idx1 = DAG->getVectorIdxConstant(1, DL);
207219

208220
SDValue Op0 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 1, Int32VT);
209221
SDValue Op1 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 2, Int32VT);
@@ -311,12 +323,14 @@ TEST_F(SelectionDAGPatternMatchTest, matchBinaryOp) {
311323
m_SpecificVT(Float32VT))));
312324

313325
EXPECT_TRUE(sd_match(SubVec, m_ExtractSubvector(m_Value(), m_Value())));
314-
EXPECT_TRUE(
315-
sd_match(SubVec, m_BinOp(ISD::EXTRACT_SUBVECTOR, m_Value(), m_Value())));
316326
EXPECT_TRUE(
317327
sd_match(SubVec, m_ExtractSubvector(m_Specific(Vec), m_Specific(Idx0))));
318-
EXPECT_TRUE(sd_match(SubVec, m_BinOp(ISD::EXTRACT_SUBVECTOR, m_Specific(Vec),
319-
m_Specific(Idx0))));
328+
EXPECT_TRUE(
329+
sd_match(SubVec, m_ExtractSubvector(m_Specific(Vec), m_SpecificInt(0))));
330+
EXPECT_FALSE(
331+
sd_match(SubVec, m_ExtractSubvector(m_Specific(Vec), m_Specific(Idx1))));
332+
EXPECT_FALSE(
333+
sd_match(SubVec, m_ExtractSubvector(m_Specific(Vec), m_SpecificInt(1))));
320334

321335
EXPECT_TRUE(
322336
sd_match(InsertELT, m_InsertElt(m_Value(), m_Value(), m_Value())));

0 commit comments

Comments
 (0)