Skip to content

Commit 6847379

Browse files
author
Simon Moll
committed
[VE] MUL,SUB,OR,XOR v256i32|64 isel
v256i32|i64 isel patterns and tests. Reviewed By: kaz7 Differential Revision: https://reviews.llvm.org/D115643
1 parent 12d4265 commit 6847379

File tree

7 files changed

+120
-40
lines changed

7 files changed

+120
-40
lines changed

llvm/lib/Target/VE/VVPInstrInfo.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ class vvp_commutative<SDNode RootOp> :
4040
def vvp_add : SDNode<"VEISD::VVP_ADD", SDTIntBinOpVVP>;
4141
def c_vvp_add : vvp_commutative<vvp_add>;
4242

43+
def vvp_sub : SDNode<"VEISD::VVP_SUB", SDTIntBinOpVVP>;
44+
45+
def vvp_mul : SDNode<"VEISD::VVP_MUL", SDTIntBinOpVVP>;
46+
def c_vvp_mul : vvp_commutative<vvp_mul>;
47+
4348
def vvp_and : SDNode<"VEISD::VVP_AND", SDTIntBinOpVVP>;
4449
def c_vvp_and : vvp_commutative<vvp_and>;
4550

51+
def vvp_or : SDNode<"VEISD::VVP_OR", SDTIntBinOpVVP>;
52+
def c_vvp_or : vvp_commutative<vvp_or>;
53+
54+
def vvp_xor : SDNode<"VEISD::VVP_XOR", SDTIntBinOpVVP>;
55+
def c_vvp_xor : vvp_commutative<vvp_xor>;
56+
4657
// } Binary Operators

llvm/lib/Target/VE/VVPInstrPatternsVec.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ multiclass Binary_rv_vv_ShortLong<
8787
defm : Binary_rv_vv_ShortLong<c_vvp_add,
8888
i64, v256i64, "VADDSL",
8989
i32, v256i32, "VADDSWSX">;
90+
defm : Binary_rv_vv_ShortLong<vvp_sub,
91+
i64, v256i64, "VSUBSL",
92+
i32, v256i32, "VSUBSWSX">;
93+
defm : Binary_rv_vv_ShortLong<c_vvp_mul,
94+
i64, v256i64, "VMULSL",
95+
i32, v256i32, "VMULSWSX">;
9096
defm : Binary_rv_vv_ShortLong<c_vvp_and,
9197
i64, v256i64, "VAND",
9298
i32, v256i32, "PVANDLO">;
99+
defm : Binary_rv_vv_ShortLong<c_vvp_or,
100+
i64, v256i64, "VOR",
101+
i32, v256i32, "PVORLO">;
102+
defm : Binary_rv_vv_ShortLong<c_vvp_xor,
103+
i64, v256i64, "VXOR",
104+
i32, v256i32, "PVXORLO">;

llvm/lib/Target/VE/VVPNodes.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333

3434
// Integer arithmetic.
3535
ADD_BINARY_VVP_OP(VVP_ADD,ADD)
36+
ADD_BINARY_VVP_OP(VVP_SUB,SUB)
37+
ADD_BINARY_VVP_OP(VVP_MUL,MUL)
3638

3739
ADD_BINARY_VVP_OP(VVP_AND,AND)
40+
ADD_BINARY_VVP_OP(VVP_OR,OR)
41+
ADD_BINARY_VVP_OP(VVP_XOR,XOR)
3842

3943
#undef HANDLE_VP_TO_VVP
4044
#undef ADD_BINARY_VVP_OP

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
; REQUIRES: asserts
2-
; RUN: not --crash llc < %s -march=ve -mattr=+vpu -o /dev/null 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -march=ve -mattr=+vpu | FileCheck %s
33

4-
; CHECK: t{{[0-9]+}}: v256i32 = vp_mul [[A:t[0-9]+]], [[B:t[0-9]+]], [[MASK:t[0-9]+]], [[EVL:t[0-9]+]]
5-
; CHECK: [[A]]: v256i32
6-
; CHECK: [[B]]: v256i32
7-
; CHECK: [[MASK]]: v256i1
8-
; CHECK: [[EVL]]: i32
4+
declare <256 x i32> @llvm.vp.mul.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
95

10-
define <256 x i32> @test_vp_int(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
6+
define fastcc <256 x i32> @test_vp_v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_v256i32:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: and %s0, %s0, (32)0
10+
; CHECK-NEXT: lvl %s0
11+
; CHECK-NEXT: vmuls.w.sx %v0, %v0, %v1, %vm1
12+
; CHECK-NEXT: b.l.t (, %s10)
1113
%r0 = call <256 x i32> @llvm.vp.mul.v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n)
1214
ret <256 x i32> %r0
1315
}
1416

15-
; integer arith
16-
declare <256 x i32> @llvm.vp.mul.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
17+
18+
declare <256 x i64> @llvm.vp.mul.v256i64(<256 x i64>, <256 x i64>, <256 x i1>, i32)
19+
20+
define fastcc <256 x i64> @test_vp_v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n) {
21+
; CHECK-LABEL: test_vp_v256i64:
22+
; CHECK: # %bb.0:
23+
; CHECK-NEXT: and %s0, %s0, (32)0
24+
; CHECK-NEXT: lvl %s0
25+
; CHECK-NEXT: vmuls.l %v0, %v0, %v1, %vm1
26+
; CHECK-NEXT: b.l.t (, %s10)
27+
%r0 = call <256 x i64> @llvm.vp.mul.v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n)
28+
ret <256 x i64> %r0
29+
}

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

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1-
; REQUIRES: asserts
2-
; RUN: not --crash llc < %s -march=ve -mattr=+vpu -o /dev/null 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -march=ve -mattr=+vpu | FileCheck %s
33

4-
; CHECK: t{{[0-9]+}}: v256i32 = vp_or [[A:t[0-9]+]], [[B:t[0-9]+]], [[MASK:t[0-9]+]], [[EVL:t[0-9]+]]
5-
; CHECK: [[A]]: v256i32
6-
; CHECK: [[B]]: v256i32
7-
; CHECK: [[MASK]]: v256i1
8-
; CHECK: [[EVL]]: i32
4+
declare <256 x i32> @llvm.vp.or.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
95

10-
define <256 x i32> @test_vp_int(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
6+
define fastcc <256 x i32> @test_vp_v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_v256i32:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: and %s0, %s0, (32)0
10+
; CHECK-NEXT: lvl %s0
11+
; CHECK-NEXT: pvor.lo %v0, %v0, %v1, %vm1
12+
; CHECK-NEXT: b.l.t (, %s10)
1113
%r0 = call <256 x i32> @llvm.vp.or.v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n)
1214
ret <256 x i32> %r0
1315
}
1416

15-
; integer arith
16-
declare <256 x i32> @llvm.vp.or.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
17+
18+
declare <256 x i64> @llvm.vp.or.v256i64(<256 x i64>, <256 x i64>, <256 x i1>, i32)
19+
20+
define fastcc <256 x i64> @test_vp_v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n) {
21+
; CHECK-LABEL: test_vp_v256i64:
22+
; CHECK: # %bb.0:
23+
; CHECK-NEXT: and %s0, %s0, (32)0
24+
; CHECK-NEXT: lvl %s0
25+
; CHECK-NEXT: vor %v0, %v0, %v1, %vm1
26+
; CHECK-NEXT: b.l.t (, %s10)
27+
%r0 = call <256 x i64> @llvm.vp.or.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_sub.ll

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
; REQUIRES: asserts
2-
; RUN: not --crash llc < %s -march=ve -mattr=+vpu -o /dev/null 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -march=ve -mattr=+vpu | FileCheck %s
33

4-
; CHECK: t{{[0-9]+}}: v256i32 = vp_sub [[A:t[0-9]+]], [[B:t[0-9]+]], [[MASK:t[0-9]+]], [[EVL:t[0-9]+]]
5-
; CHECK: [[A]]: v256i32
6-
; CHECK: [[B]]: v256i32
7-
; CHECK: [[MASK]]: v256i1
8-
; CHECK: [[EVL]]: i32
4+
declare <256 x i32> @llvm.vp.sub.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
95

10-
define <256 x i32> @test_vp_int(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
6+
define fastcc <256 x i32> @test_vp_v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_v256i32:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: and %s0, %s0, (32)0
10+
; CHECK-NEXT: lvl %s0
11+
; CHECK-NEXT: vsubs.w.sx %v0, %v0, %v1, %vm1
12+
; CHECK-NEXT: b.l.t (, %s10)
1113
%r0 = call <256 x i32> @llvm.vp.sub.v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n)
1214
ret <256 x i32> %r0
1315
}
1416

15-
; integer arith
16-
declare <256 x i32> @llvm.vp.sub.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
17+
18+
declare <256 x i64> @llvm.vp.sub.v256i64(<256 x i64>, <256 x i64>, <256 x i1>, i32)
19+
20+
define fastcc <256 x i64> @test_vp_v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n) {
21+
; CHECK-LABEL: test_vp_v256i64:
22+
; CHECK: # %bb.0:
23+
; CHECK-NEXT: and %s0, %s0, (32)0
24+
; CHECK-NEXT: lvl %s0
25+
; CHECK-NEXT: vsubs.l %v0, %v0, %v1, %vm1
26+
; CHECK-NEXT: b.l.t (, %s10)
27+
%r0 = call <256 x i64> @llvm.vp.sub.v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n)
28+
ret <256 x i64> %r0
29+
}

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
; REQUIRES: asserts
2-
; RUN: not --crash llc < %s -march=ve -mattr=+vpu -o /dev/null 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -march=ve -mattr=+vpu | FileCheck %s
33

4-
; CHECK: t{{[0-9]+}}: v256i32 = vp_xor [[A:t[0-9]+]], [[B:t[0-9]+]], [[MASK:t[0-9]+]], [[EVL:t[0-9]+]]
5-
; CHECK: [[A]]: v256i32
6-
; CHECK: [[B]]: v256i32
7-
; CHECK: [[MASK]]: v256i1
8-
; CHECK: [[EVL]]: i32
4+
declare <256 x i32> @llvm.vp.xor.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
95

10-
define <256 x i32> @test_vp_int(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
6+
define fastcc <256 x i32> @test_vp_v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n) {
7+
; CHECK-LABEL: test_vp_v256i32:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: and %s0, %s0, (32)0
10+
; CHECK-NEXT: lvl %s0
11+
; CHECK-NEXT: pvxor.lo %v0, %v0, %v1, %vm1
12+
; CHECK-NEXT: b.l.t (, %s10)
1113
%r0 = call <256 x i32> @llvm.vp.xor.v256i32(<256 x i32> %i0, <256 x i32> %i1, <256 x i1> %m, i32 %n)
1214
ret <256 x i32> %r0
1315
}
1416

15-
; integer arith
16-
declare <256 x i32> @llvm.vp.xor.v256i32(<256 x i32>, <256 x i32>, <256 x i1>, i32)
17+
18+
declare <256 x i64> @llvm.vp.xor.v256i64(<256 x i64>, <256 x i64>, <256 x i1>, i32)
19+
20+
define fastcc <256 x i64> @test_vp_v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n) {
21+
; CHECK-LABEL: test_vp_v256i64:
22+
; CHECK: # %bb.0:
23+
; CHECK-NEXT: and %s0, %s0, (32)0
24+
; CHECK-NEXT: lvl %s0
25+
; CHECK-NEXT: vxor %v0, %v0, %v1, %vm1
26+
; CHECK-NEXT: b.l.t (, %s10)
27+
%r0 = call <256 x i64> @llvm.vp.xor.v256i64(<256 x i64> %i0, <256 x i64> %i1, <256 x i1> %m, i32 %n)
28+
ret <256 x i64> %r0
29+
}

0 commit comments

Comments
 (0)