Skip to content

Commit f5d5291

Browse files
author
Kai Luo
committed
[PowerPC] Pre-commit neg abs test for vector. NFC.
1 parent 12b6c5e commit f5d5291

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

llvm/test/CodeGen/PowerPC/neg-abs.ll

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
; RUN: -check-prefix=CHECK-LE %s
55

66
declare i64 @llvm.abs.i64(i64, i1 immarg)
7+
declare <2 x i64> @llvm.abs.v2i64(<2 x i64>, i1)
8+
declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1)
9+
declare <8 x i16> @llvm.abs.v8i16(<8 x i16>, i1)
10+
declare <16 x i8> @llvm.abs.v16i8(<16 x i8>, i1)
711

812
define i64@neg_abs(i64 %x) {
913
; CHECK-LE-LABEL: neg_abs:
@@ -16,3 +20,60 @@ define i64@neg_abs(i64 %x) {
1620
%neg = sub nsw i64 0, %abs
1721
ret i64 %neg
1822
}
23+
24+
define <2 x i64> @neg_abs_v2i64(<2 x i64> %0) {
25+
; CHECK-LE-LABEL: neg_abs_v2i64:
26+
; CHECK-LE: # %bb.0:
27+
; CHECK-LE-NEXT: addis r3, r2, .LCPI1_0@toc@ha
28+
; CHECK-LE-NEXT: addi r3, r3, .LCPI1_0@toc@l
29+
; CHECK-LE-NEXT: lxvd2x vs0, 0, r3
30+
; CHECK-LE-NEXT: xxswapd vs35, vs0
31+
; CHECK-LE-NEXT: vsrad v3, v2, v3
32+
; CHECK-LE-NEXT: xxlxor vs34, vs34, vs35
33+
; CHECK-LE-NEXT: vsubudm v2, v3, v2
34+
; CHECK-LE-NEXT: blr
35+
%abs = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %0, i1 true)
36+
%neg.abs = sub <2 x i64> zeroinitializer, %abs
37+
ret <2 x i64> %neg.abs
38+
}
39+
40+
define <4 x i32> @neg_abs_v4i32(<4 x i32> %0) {
41+
; CHECK-LE-LABEL: neg_abs_v4i32:
42+
; CHECK-LE: # %bb.0:
43+
; CHECK-LE-NEXT: vspltisw v3, -16
44+
; CHECK-LE-NEXT: vspltisw v4, 15
45+
; CHECK-LE-NEXT: vsubuwm v3, v4, v3
46+
; CHECK-LE-NEXT: vsraw v3, v2, v3
47+
; CHECK-LE-NEXT: xxlxor vs34, vs34, vs35
48+
; CHECK-LE-NEXT: vsubuwm v2, v3, v2
49+
; CHECK-LE-NEXT: blr
50+
%abs = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %0, i1 true)
51+
%neg.abs = sub <4 x i32> zeroinitializer, %abs
52+
ret <4 x i32> %neg.abs
53+
}
54+
55+
define <8 x i16> @neg_abs_v8i16(<8 x i16> %0) {
56+
; CHECK-LE-LABEL: neg_abs_v8i16:
57+
; CHECK-LE: # %bb.0:
58+
; CHECK-LE-NEXT: vspltish v3, 15
59+
; CHECK-LE-NEXT: vsrah v3, v2, v3
60+
; CHECK-LE-NEXT: xxlxor vs34, vs34, vs35
61+
; CHECK-LE-NEXT: vsubuhm v2, v3, v2
62+
; CHECK-LE-NEXT: blr
63+
%abs = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %0, i1 true)
64+
%neg.abs = sub <8 x i16> zeroinitializer, %abs
65+
ret <8 x i16> %neg.abs
66+
}
67+
68+
define <16 x i8> @neg_abs_v16i8(<16 x i8> %0) {
69+
; CHECK-LE-LABEL: neg_abs_v16i8:
70+
; CHECK-LE: # %bb.0:
71+
; CHECK-LE-NEXT: vspltisb v3, 7
72+
; CHECK-LE-NEXT: vsrab v3, v2, v3
73+
; CHECK-LE-NEXT: xxlxor vs34, vs34, vs35
74+
; CHECK-LE-NEXT: vsububm v2, v3, v2
75+
; CHECK-LE-NEXT: blr
76+
%abs = call <16 x i8> @llvm.abs.v16i8(<16 x i8> %0, i1 true)
77+
%neg.abs = sub <16 x i8> zeroinitializer, %abs
78+
ret <16 x i8> %neg.abs
79+
}

0 commit comments

Comments
 (0)