Skip to content

Commit 31cca9e

Browse files
author
Simon Moll
committed
[VE] Packed v512f32 binop isel and tests
Reviewed By: kaz7 Differential Revision: https://reviews.llvm.org/D118335
1 parent 16d464a commit 31cca9e

File tree

4 files changed

+169
-0
lines changed

4 files changed

+169
-0
lines changed

llvm/lib/Target/VE/VVPInstrPatternsVec.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ defm : Binary_rv_vr_vv_ShortLong<vvp_fdiv,
237237
f64, v256f64, "VFDIVD",
238238
f32, v256f32, "VFDIVS">;
239239

240+
defm : Binary_rv_vv<c_vvp_fadd,
241+
i64, v512f32, v512i1, "PVFADD">;
242+
defm : Binary_rv_vv<c_vvp_fmul,
243+
i64, v512f32, v512i1, "PVFMUL">;
244+
defm : Binary_rv_vv<vvp_fsub,
245+
i64, v512f32, v512i1, "PVFSUB">;
246+
240247
multiclass Merge_mvv<
241248
SDPatternOperator OpNode,
242249
ValueType DataVT, ValueType MaskVT,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 <512 x float> @llvm.vp.fadd.v512f32(<512 x float>, <512 x float>, <512 x i1>, i32)
5+
6+
define fastcc <512 x float> @test_vp_fadd_v512f32_vv(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_fadd_v512f32_vv:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: adds.w.sx %s0, 1, %s0
10+
; CHECK-NEXT: and %s0, %s0, (32)0
11+
; CHECK-NEXT: srl %s0, %s0, 1
12+
; CHECK-NEXT: lvl %s0
13+
; CHECK-NEXT: pvfadd %v0, %v0, %v1, %vm2
14+
; CHECK-NEXT: b.l.t (, %s10)
15+
%r0 = call <512 x float> @llvm.vp.fadd.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
16+
ret <512 x float> %r0
17+
}
18+
19+
define fastcc <512 x float> @test_vp_fadd_v512f32_rv(float %s0, <512 x float> %i1, <512 x i1> %m, i32 %n) {
20+
; CHECK-LABEL: test_vp_fadd_v512f32_rv:
21+
; CHECK: # %bb.0:
22+
; CHECK-NEXT: and %s2, %s0, (32)1
23+
; CHECK-NEXT: srl %s0, %s0, 32
24+
; CHECK-NEXT: or %s0, %s0, %s2
25+
; CHECK-NEXT: adds.w.sx %s1, 1, %s1
26+
; CHECK-NEXT: and %s1, %s1, (32)0
27+
; CHECK-NEXT: srl %s1, %s1, 1
28+
; CHECK-NEXT: lvl %s1
29+
; CHECK-NEXT: pvfadd %v0, %s0, %v0, %vm2
30+
; CHECK-NEXT: b.l.t (, %s10)
31+
%xins = insertelement <512 x float> undef, float %s0, i32 0
32+
%i0 = shufflevector <512 x float> %xins, <512 x float> undef, <512 x i32> zeroinitializer
33+
%r0 = call <512 x float> @llvm.vp.fadd.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
34+
ret <512 x float> %r0
35+
}
36+
37+
define fastcc <512 x float> @test_vp_fadd_v512f32_vr(<512 x float> %i0, float %s1, <512 x i1> %m, i32 %n) {
38+
; CHECK-LABEL: test_vp_fadd_v512f32_vr:
39+
; CHECK: # %bb.0:
40+
; CHECK-NEXT: and %s2, %s0, (32)1
41+
; CHECK-NEXT: srl %s0, %s0, 32
42+
; CHECK-NEXT: or %s0, %s0, %s2
43+
; CHECK-NEXT: adds.w.sx %s1, 1, %s1
44+
; CHECK-NEXT: and %s1, %s1, (32)0
45+
; CHECK-NEXT: srl %s1, %s1, 1
46+
; CHECK-NEXT: lvl %s1
47+
; CHECK-NEXT: pvfadd %v0, %s0, %v0, %vm2
48+
; CHECK-NEXT: b.l.t (, %s10)
49+
%yins = insertelement <512 x float> undef, float %s1, i32 0
50+
%i1 = shufflevector <512 x float> %yins, <512 x float> undef, <512 x i32> zeroinitializer
51+
%r0 = call <512 x float> @llvm.vp.fadd.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
52+
ret <512 x float> %r0
53+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 <512 x float> @llvm.vp.fmul.v512f32(<512 x float>, <512 x float>, <512 x i1>, i32)
5+
6+
define fastcc <512 x float> @test_vp_fmul_v512f32_vv(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_fmul_v512f32_vv:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: adds.w.sx %s0, 1, %s0
10+
; CHECK-NEXT: and %s0, %s0, (32)0
11+
; CHECK-NEXT: srl %s0, %s0, 1
12+
; CHECK-NEXT: lvl %s0
13+
; CHECK-NEXT: pvfmul %v0, %v0, %v1, %vm2
14+
; CHECK-NEXT: b.l.t (, %s10)
15+
%r0 = call <512 x float> @llvm.vp.fmul.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
16+
ret <512 x float> %r0
17+
}
18+
19+
define fastcc <512 x float> @test_vp_fmul_v512f32_rv(float %s0, <512 x float> %i1, <512 x i1> %m, i32 %n) {
20+
; CHECK-LABEL: test_vp_fmul_v512f32_rv:
21+
; CHECK: # %bb.0:
22+
; CHECK-NEXT: and %s2, %s0, (32)1
23+
; CHECK-NEXT: srl %s0, %s0, 32
24+
; CHECK-NEXT: or %s0, %s0, %s2
25+
; CHECK-NEXT: adds.w.sx %s1, 1, %s1
26+
; CHECK-NEXT: and %s1, %s1, (32)0
27+
; CHECK-NEXT: srl %s1, %s1, 1
28+
; CHECK-NEXT: lvl %s1
29+
; CHECK-NEXT: pvfmul %v0, %s0, %v0, %vm2
30+
; CHECK-NEXT: b.l.t (, %s10)
31+
%xins = insertelement <512 x float> undef, float %s0, i32 0
32+
%i0 = shufflevector <512 x float> %xins, <512 x float> undef, <512 x i32> zeroinitializer
33+
%r0 = call <512 x float> @llvm.vp.fmul.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
34+
ret <512 x float> %r0
35+
}
36+
37+
define fastcc <512 x float> @test_vp_fmul_v512f32_vr(<512 x float> %i0, float %s1, <512 x i1> %m, i32 %n) {
38+
; CHECK-LABEL: test_vp_fmul_v512f32_vr:
39+
; CHECK: # %bb.0:
40+
; CHECK-NEXT: and %s2, %s0, (32)1
41+
; CHECK-NEXT: srl %s0, %s0, 32
42+
; CHECK-NEXT: or %s0, %s0, %s2
43+
; CHECK-NEXT: adds.w.sx %s1, 1, %s1
44+
; CHECK-NEXT: and %s1, %s1, (32)0
45+
; CHECK-NEXT: srl %s1, %s1, 1
46+
; CHECK-NEXT: lvl %s1
47+
; CHECK-NEXT: pvfmul %v0, %s0, %v0, %vm2
48+
; CHECK-NEXT: b.l.t (, %s10)
49+
%yins = insertelement <512 x float> undef, float %s1, i32 0
50+
%i1 = shufflevector <512 x float> %yins, <512 x float> undef, <512 x i32> zeroinitializer
51+
%r0 = call <512 x float> @llvm.vp.fmul.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
52+
ret <512 x float> %r0
53+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 <512 x float> @llvm.vp.fsub.v512f32(<512 x float>, <512 x float>, <512 x i1>, i32)
5+
6+
define fastcc <512 x float> @test_vp_fsub_v512f32_vv(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_fsub_v512f32_vv:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: adds.w.sx %s0, 1, %s0
10+
; CHECK-NEXT: and %s0, %s0, (32)0
11+
; CHECK-NEXT: srl %s0, %s0, 1
12+
; CHECK-NEXT: lvl %s0
13+
; CHECK-NEXT: pvfsub %v0, %v0, %v1, %vm2
14+
; CHECK-NEXT: b.l.t (, %s10)
15+
%r0 = call <512 x float> @llvm.vp.fsub.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
16+
ret <512 x float> %r0
17+
}
18+
19+
define fastcc <512 x float> @test_vp_fsub_v512f32_rv(float %s0, <512 x float> %i1, <512 x i1> %m, i32 %n) {
20+
; CHECK-LABEL: test_vp_fsub_v512f32_rv:
21+
; CHECK: # %bb.0:
22+
; CHECK-NEXT: and %s2, %s0, (32)1
23+
; CHECK-NEXT: srl %s0, %s0, 32
24+
; CHECK-NEXT: or %s0, %s0, %s2
25+
; CHECK-NEXT: adds.w.sx %s1, 1, %s1
26+
; CHECK-NEXT: and %s1, %s1, (32)0
27+
; CHECK-NEXT: srl %s1, %s1, 1
28+
; CHECK-NEXT: lvl %s1
29+
; CHECK-NEXT: pvfsub %v0, %s0, %v0, %vm2
30+
; CHECK-NEXT: b.l.t (, %s10)
31+
%xins = insertelement <512 x float> undef, float %s0, i32 0
32+
%i0 = shufflevector <512 x float> %xins, <512 x float> undef, <512 x i32> zeroinitializer
33+
%r0 = call <512 x float> @llvm.vp.fsub.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
34+
ret <512 x float> %r0
35+
}
36+
37+
define fastcc <512 x float> @test_vp_fsub_v512f32_vr(<512 x float> %i0, float %s1, <512 x i1> %m, i32 %n) {
38+
; CHECK-LABEL: test_vp_fsub_v512f32_vr:
39+
; CHECK: # %bb.0:
40+
; CHECK-NEXT: and %s2, %s0, (32)1
41+
; CHECK-NEXT: srl %s0, %s0, 32
42+
; CHECK-NEXT: or %s0, %s0, %s2
43+
; CHECK-NEXT: lea %s2, 256
44+
; CHECK-NEXT: lvl %s2
45+
; CHECK-NEXT: vbrd %v1, %s0
46+
; CHECK-NEXT: adds.w.sx %s0, 1, %s1
47+
; CHECK-NEXT: and %s0, %s0, (32)0
48+
; CHECK-NEXT: srl %s0, %s0, 1
49+
; CHECK-NEXT: lvl %s0
50+
; CHECK-NEXT: pvfsub %v0, %v0, %v1, %vm2
51+
; CHECK-NEXT: b.l.t (, %s10)
52+
%yins = insertelement <512 x float> undef, float %s1, i32 0
53+
%i1 = shufflevector <512 x float> %yins, <512 x float> undef, <512 x i32> zeroinitializer
54+
%r0 = call <512 x float> @llvm.vp.fsub.v512f32(<512 x float> %i0, <512 x float> %i1, <512 x i1> %m, i32 %n)
55+
ret <512 x float> %r0
56+
}

0 commit comments

Comments
 (0)