Skip to content

Commit 74db2f5

Browse files
authored
Merge pull request #128 from sx-aurora-dev/merge/vp-shift-visel
Merge/vp shift visel
2 parents ad3e360 + baf5ffa commit 74db2f5

File tree

3 files changed

+82
-7
lines changed

3 files changed

+82
-7
lines changed

llvm/lib/Target/VE/VVPInstrPatternsVec.td

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,6 @@ multiclass Binary_vr_vv<
219219
defm : Binary_vr<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
220220
defm : Binary_vv<OpNode, DataVT, MaskVT, OpBaseName>;
221221
}
222-
multiclass Binary_vr_vv_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
223-
defm : Binary_vr_vv<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
224-
defm : Binary_vr_vv<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
225-
}
226222

227223
// Binary operators that support broadcasts only on LHS.
228224
multiclass Binary_rv_vv<
@@ -233,6 +229,7 @@ multiclass Binary_rv_vv<
233229
defm : Binary_vv<OpNode, DataVT, MaskVT, OpBaseName>;
234230
}
235231

232+
// Expand both 64bit and 32 bit variant (256 elements)
236233
multiclass Binary_rv_vv_ShortLong<
237234
SDPatternOperator OpNode,
238235
ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
@@ -245,6 +242,18 @@ multiclass Binary_rv_vv_ShortLong<
245242
ShortOpBaseName>;
246243
}
247244

245+
multiclass Binary_vr_vv_ShortLong<
246+
SDPatternOperator OpNode,
247+
ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
248+
ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
249+
defm : Binary_vr_vv<OpNode,
250+
LongScalarVT, LongDataVT, v256i1,
251+
LongOpBaseName>;
252+
defm : Binary_vr_vv<OpNode,
253+
ShortScalarVT, ShortDataVT, v256i1,
254+
ShortOpBaseName>;
255+
}
256+
248257
// Binary operators that support broadcasts on LHS and RHS.
249258
multiclass Binary_all<
250259
SDPatternOperator OpNode,
@@ -345,9 +354,15 @@ defm : Binary_rv_vv_ShortLong<c_vvp_xor,
345354
defm : Binary_ShortLong<vvp_sdiv, i64, v256i64, "VDIVSL", i32, v256i32, "VDIVSWSX">;
346355
defm : Binary_ShortLong<vvp_udiv, i64, v256i64, "VDIVUL", i32, v256i32, "VDIVUW">;
347356

348-
defm : Binary_vr_vv_ShortLong<vvp_srl, i64, v256i64, "VSRL", i32, v256i32, "PVSRLLO">;
349-
defm : Binary_vr_vv_ShortLong<vvp_sra, i64, v256i64, "VSRAL", i32, v256i32, "PVSRALO">;
350-
defm : Binary_vr_vv_ShortLong<vvp_shl, i64, v256i64, "VSLL", i32, v256i32, "PVSLLLO">;
357+
defm : Binary_vr_vv_ShortLong<vvp_shl,
358+
i64, v256i64, "VSLL",
359+
i32, v256i32, "PVSLLLO">;
360+
defm : Binary_vr_vv_ShortLong<vvp_sra,
361+
i64, v256i64, "VSRAL",
362+
i32, v256i32, "PVSRALO">;
363+
defm : Binary_vr_vv_ShortLong<vvp_srl,
364+
i64, v256i64, "VSRL",
365+
i32, v256i32, "PVSRLLO">;
351366

352367
// Floating-point arithmetic (256 elements)
353368
defm : Unary_ShortLong<vvp_frcp, f64, v256f64, "VRCPD", f32, v256f32, "VRCPS">;

llvm/test/CodeGen/VE/Vector/vp_sra.ll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -march=ve -mattr=+vpu | FileCheck %s
3+
4+
declare <256 x i32> @llvm.vp.ashr.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
5+
6+
define fastcc <256 x i32> @test_vp_ashr_v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_ashr_v256i32:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: and %s0, %s0, (32)0
10+
; CHECK-NEXT: lvl %s0
11+
; CHECK-NEXT: pvsra.lo %v0, %v0, %v1
12+
; CHECK-NEXT: b.l.t (, %s10)
13+
%r0 = call <256 x i32> @llvm.vp.ashr.v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n)
14+
ret <256 x i32> %r0
15+
}
16+
17+
18+
declare <256 x i64> @llvm.vp.ashr.v256i64(<256 x i64>, <256 x i64>, <256 x i1>, i32)
19+
20+
define fastcc <256 x i64> @test_vp_int_v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n) {
21+
; CHECK-LABEL: test_vp_int_v256i64:
22+
; CHECK: # %bb.0:
23+
; CHECK-NEXT: and %s0, %s0, (32)0
24+
; CHECK-NEXT: lvl %s0
25+
; CHECK-NEXT: vsra.l %v0, %v0, %v1
26+
; CHECK-NEXT: b.l.t (, %s10)
27+
%r0 = call <256 x i64> @llvm.vp.ashr.v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n)
28+
ret <256 x i64> %r0
29+
}
30+

llvm/test/CodeGen/VE/Vector/vp_srl.ll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -march=ve -mattr=+vpu | FileCheck %s
3+
4+
declare <256 x i32> @llvm.vp.lshr.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
5+
6+
define fastcc <256 x i32> @test_vp_lshr_v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_lshr_v256i32:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: and %s0, %s0, (32)0
10+
; CHECK-NEXT: lvl %s0
11+
; CHECK-NEXT: pvsrl.lo %v0, %v0, %v1
12+
; CHECK-NEXT: b.l.t (, %s10)
13+
%r0 = call <256 x i32> @llvm.vp.lshr.v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n)
14+
ret <256 x i32> %r0
15+
}
16+
17+
18+
declare <256 x i64> @llvm.vp.lshr.v256i64(<256 x i64>, <256 x i64>, <256 x i1>, i32)
19+
20+
define fastcc <256 x i64> @test_vp_int_v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n) {
21+
; CHECK-LABEL: test_vp_int_v256i64:
22+
; CHECK: # %bb.0:
23+
; CHECK-NEXT: and %s0, %s0, (32)0
24+
; CHECK-NEXT: lvl %s0
25+
; CHECK-NEXT: vsrl %v0, %v0, %v1
26+
; CHECK-NEXT: b.l.t (, %s10)
27+
%r0 = call <256 x i64> @llvm.vp.lshr.v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n)
28+
ret <256 x i64> %r0
29+
}
30+

0 commit comments

Comments
 (0)