Skip to content

Commit 1ea8967

Browse files
authored
Merge pull request #121 from sx-aurora-dev/merge/vp-pattern-cleanup
Merge/vp pattern cleanup
2 parents 5682922 + d3f6677 commit 1ea8967

File tree

1 file changed

+68
-73
lines changed

1 file changed

+68
-73
lines changed

llvm/lib/Target/VE/VVPInstrPatternsVec.td

Lines changed: 68 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -16,57 +16,6 @@
1616
//
1717
//===----------------------------------------------------------------------===//
1818

19-
multiclass VectorBinaryArith<
20-
SDPatternOperator OpNode,
21-
ValueType ScalarVT, ValueType DataVT, ValueType MaskVT,
22-
string OpBaseName> {
23-
// No mask.
24-
def : Pat<(OpNode
25-
(any_broadcast ScalarVT:$sx),
26-
DataVT:$vy, (MaskVT true_mask), i32:$avl),
27-
(!cast<Instruction>(OpBaseName#"rvl")
28-
ScalarVT:$sx, $vy, $avl)>;
29-
def : Pat<(OpNode DataVT:$vx, DataVT:$vy, (MaskVT true_mask), i32:$avl),
30-
(!cast<Instruction>(OpBaseName#"vvl")
31-
$vx, $vy, $avl)>;
32-
33-
// Mask.
34-
def : Pat<(OpNode
35-
(any_broadcast ScalarVT:$sx),
36-
DataVT:$vy, MaskVT:$mask, i32:$avl),
37-
(!cast<Instruction>(OpBaseName#"rvml")
38-
ScalarVT:$sx, $vy, $mask, $avl)>;
39-
def : Pat<(OpNode DataVT:$vx, DataVT:$vy, MaskVT:$mask, i32:$avl),
40-
(!cast<Instruction>(OpBaseName#"vvml")
41-
$vx, $vy, $mask, $avl)>;
42-
43-
// TODO We do not specify patterns for the immediate variants here. There
44-
// will be an immediate folding pass that takes care of switching to the
45-
// immediate variant where applicable.
46-
47-
// TODO Fold vvp_select into passthru.
48-
}
49-
50-
// Expand both 64bit and 32 bit variant (256 elements)
51-
multiclass VectorBinaryArith_ShortLong<
52-
SDPatternOperator OpNode,
53-
ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
54-
ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
55-
defm : VectorBinaryArith<OpNode,
56-
LongScalarVT, LongDataVT, v256i1,
57-
LongOpBaseName>;
58-
defm : VectorBinaryArith<OpNode,
59-
ShortScalarVT, ShortDataVT, v256i1,
60-
ShortOpBaseName>;
61-
}
62-
63-
64-
defm : VectorBinaryArith_ShortLong<c_vvp_add,
65-
i64, v256i64, "VADDSL",
66-
i32, v256i32, "VADDSWSX">;
67-
defm : VectorBinaryArith_ShortLong<c_vvp_and,
68-
i64, v256i64, "VAND",
69-
i32, v256i32, "PVANDLO">;
7019

7120
// Vector Gather and scatter
7221
multiclass VectorGather<ValueType DataVT, ValueType PtrVT, ValueType MaskVT, string GTPrefix> {
@@ -206,7 +155,12 @@ multiclass Unary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, Val
206155

207156

208157

209-
multiclass Binary_rv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
158+
159+
// Expand both 64bit and 32 bit variant (256 elements)
160+
161+
multiclass Binary_rv<SDPatternOperator OpNode,
162+
ValueType ScalarVT, ValueType DataVT,
163+
ValueType MaskVT, string OpBaseName> {
210164
// Masked with select, broadcast.
211165
def : Pat<(vvp_select (OpNode (any_broadcast ScalarVT:$sx), DataVT:$vy, (MaskVT srcvalue), (i32 srcvalue)),
212166
DataVT:$vfalse,
@@ -221,7 +175,9 @@ multiclass Binary_rv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType Dat
221175
(!cast<Instruction>(OpBaseName#"rvml") ScalarVT:$sx, $vy, $mask, $avl)>;
222176
}
223177

224-
multiclass Binary_vr<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
178+
multiclass Binary_vr<SDPatternOperator OpNode,
179+
ValueType ScalarVT, ValueType DataVT,
180+
ValueType MaskVT, string OpBaseName> {
225181
// Masked with select, broadcast.
226182
def : Pat<(vvp_select (OpNode DataVT:$vx, (DataVT (any_broadcast ScalarVT:$sy)), (MaskVT srcvalue), (i32 srcvalue)),
227183
DataVT:$vfalse,
@@ -236,7 +192,9 @@ multiclass Binary_vr<SDPatternOperator OpNode, ValueType ScalarVT, ValueType Dat
236192
(!cast<Instruction>(OpBaseName#"vrml") $vx, ScalarVT:$sy, $mask, $avl)>;
237193
}
238194

239-
multiclass Binary_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
195+
multiclass Binary_vv<SDPatternOperator OpNode,
196+
ValueType DataVT,
197+
ValueType MaskVT, string OpBaseName> {
240198
// Masked with select.
241199
def : Pat<(vvp_select (OpNode DataVT:$vx, DataVT:$vy, (MaskVT srcvalue), (i32 srcvalue)),
242200
DataVT:$vfalse,
@@ -254,37 +212,60 @@ multiclass Binary_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType Dat
254212
}
255213

256214
// Binary operators that support broadcasts only on RHS.
257-
multiclass Binary_vr_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
215+
multiclass Binary_vr_vv<
216+
SDPatternOperator OpNode,
217+
ValueType ScalarVT, ValueType DataVT, ValueType MaskVT,
218+
string OpBaseName> {
258219
defm : Binary_vr<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
259-
defm : Binary_vv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
220+
defm : Binary_vv<OpNode, DataVT, MaskVT, OpBaseName>;
260221
}
261222
multiclass Binary_vr_vv_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
262223
defm : Binary_vr_vv<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
263224
defm : Binary_vr_vv<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
264225
}
265226

266227
// Binary operators that support broadcasts only on LHS.
267-
multiclass Binary_rv_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
228+
multiclass Binary_rv_vv<
229+
SDPatternOperator OpNode,
230+
ValueType ScalarVT, ValueType DataVT, ValueType MaskVT,
231+
string OpBaseName> {
268232
defm : Binary_rv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
269-
defm : Binary_vv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
233+
defm : Binary_vv<OpNode, DataVT, MaskVT, OpBaseName>;
270234
}
271-
multiclass Binary_rv_vv_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
272-
defm : Binary_rv_vv<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
273-
defm : Binary_rv_vv<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
235+
236+
multiclass Binary_rv_vv_ShortLong<
237+
SDPatternOperator OpNode,
238+
ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
239+
ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
240+
defm : Binary_rv_vv<OpNode,
241+
LongScalarVT, LongDataVT, v256i1,
242+
LongOpBaseName>;
243+
defm : Binary_rv_vv<OpNode,
244+
ShortScalarVT, ShortDataVT, v256i1,
245+
ShortOpBaseName>;
274246
}
275247

276248
// Binary operators that support broadcasts on LHS and RHS.
277-
multiclass Binary_all<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
249+
multiclass Binary_all<
250+
SDPatternOperator OpNode,
251+
ValueType ScalarVT, ValueType DataVT,
252+
ValueType MaskVT, string OpBaseName> {
278253
defm : Binary_rv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
279254
defm : Binary_vr_vv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
280255
}
281-
multiclass Binary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
256+
257+
multiclass Binary_ShortLong<
258+
SDPatternOperator OpNode,
259+
ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
260+
ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
282261
defm : Binary_all<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
283262
defm : Binary_all<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
284263
}
285264

286-
287-
multiclass Ternary<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
265+
multiclass Ternary<
266+
SDPatternOperator OpNode,
267+
ValueType ScalarVT, ValueType DataVT,
268+
ValueType MaskVT, string OpBaseName> {
288269
//// Mask + vvp_select /////
289270
// with mask, broadcast first
290271
def : Pat<(vvp_select
@@ -330,7 +311,10 @@ multiclass Ternary<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataV
330311
}
331312

332313
// Expand both 64bit and 32 bit variant (256 elements)
333-
multiclass Ternary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
314+
multiclass Ternary_ShortLong<
315+
SDPatternOperator OpNode,
316+
ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
317+
ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
334318
defm : Ternary<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
335319
defm : Ternary<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
336320
}
@@ -339,21 +323,32 @@ multiclass Ternary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, V
339323
// Integer arithmetic (256 elements)
340324
defm : Unary_ShortLong<vvp_ctpop, i64, v256i64, "VPCNT", i32, v256i32, "PVPCNTLO">;
341325

342-
defm : Binary_rv_vv_ShortLong<c_vvp_add, i64, v256i64, "VADDSL", i32, v256i32, "VADDSWSX">;
326+
defm : Binary_rv_vv_ShortLong<c_vvp_add,
327+
i64, v256i64, "VADDSL",
328+
i32, v256i32, "VADDSWSX">;
329+
defm : Binary_rv_vv_ShortLong<vvp_sub,
330+
i64, v256i64, "VSUBSL",
331+
i32, v256i32, "VSUBSWSX">;
332+
defm : Binary_rv_vv_ShortLong<c_vvp_mul,
333+
i64, v256i64, "VMULSL",
334+
i32, v256i32, "VMULSWSX">;
335+
defm : Binary_rv_vv_ShortLong<c_vvp_and,
336+
i64, v256i64, "VAND",
337+
i32, v256i32, "PVANDLO">;
338+
defm : Binary_rv_vv_ShortLong<c_vvp_or,
339+
i64, v256i64, "VOR",
340+
i32, v256i32, "PVORLO">;
341+
defm : Binary_rv_vv_ShortLong<c_vvp_xor,
342+
i64, v256i64, "VXOR",
343+
i32, v256i32, "PVXORLO">;
343344

344-
defm : Binary_rv_vv_ShortLong<vvp_sub, i64, v256i64, "VSUBSL", i32, v256i32, "VSUBSWSX">;
345-
defm : Binary_rv_vv_ShortLong<c_vvp_mul, i64, v256i64, "VMULSL", i32, v256i32, "VMULSWSX">;
346345
defm : Binary_ShortLong<vvp_sdiv, i64, v256i64, "VDIVSL", i32, v256i32, "VDIVSWSX">;
347346
defm : Binary_ShortLong<vvp_udiv, i64, v256i64, "VDIVUL", i32, v256i32, "VDIVUW">;
348347

349348
defm : Binary_vr_vv_ShortLong<vvp_srl, i64, v256i64, "VSRL", i32, v256i32, "PVSRLLO">;
350349
defm : Binary_vr_vv_ShortLong<vvp_sra, i64, v256i64, "VSRAL", i32, v256i32, "PVSRALO">;
351350
defm : Binary_vr_vv_ShortLong<vvp_shl, i64, v256i64, "VSLL", i32, v256i32, "PVSLLLO">;
352351

353-
defm : Binary_rv_vv_ShortLong<c_vvp_and, i64, v256i64, "VAND", i32, v256i32, "PVANDLO">;
354-
defm : Binary_rv_vv_ShortLong<c_vvp_xor, i64, v256i64, "VXOR", i32, v256i32, "PVXORLO">;
355-
defm : Binary_rv_vv_ShortLong<c_vvp_or, i64, v256i64, "VOR", i32, v256i32, "PVORLO">;
356-
357352
// Floating-point arithmetic (256 elements)
358353
defm : Unary_ShortLong<vvp_frcp, f64, v256f64, "VRCPD", f32, v256f32, "VRCPS">;
359354
defm : Unary_ShortLong<vvp_fsqrt, f64, v256f64, "VFSQRTD", f32, v256f32, "VFSQRTS">;

0 commit comments

Comments
 (0)