Skip to content

Commit 97fb91e

Browse files
committed
[SLP][NFC]Add a test with non-profitable alternate vectorized
instructions.
1 parent 6095f8b commit 97fb91e

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -S -passes=slp-vectorizer -slp-threshold=-10000 < %s | FileCheck %s
3+
4+
define <2 x float> @test_fdiv(float %a, i1 %cmp) {
5+
; CHECK-LABEL: define <2 x float> @test_fdiv(
6+
; CHECK-SAME: float [[A:%.*]], i1 [[CMP:%.*]]) {
7+
; CHECK-NEXT: [[TMP1:%.*]] = fdiv float [[A]], 3.000000e+00
8+
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x float> poison, float [[TMP1]], i64 1
9+
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[CMP]], <2 x float> <float 7.700000e+01, float 9.900000e+01>, <2 x float> [[TMP2]]
10+
; CHECK-NEXT: ret <2 x float> [[TMP3]]
11+
;
12+
%1 = fdiv float %a, 3.000000e+00
13+
%2 = insertelement <2 x float> poison, float %1, i64 1
14+
%3 = select i1 %cmp, <2 x float> <float 7.700000e+01, float 9.900000e+01>, <2 x float> %2
15+
ret <2 x float> %3
16+
}
17+
18+
define <2 x float> @test_frem(float %a, i1 %cmp) {
19+
; CHECK-LABEL: define <2 x float> @test_frem(
20+
; CHECK-SAME: float [[A:%.*]], i1 [[CMP:%.*]]) {
21+
; CHECK-NEXT: [[TMP1:%.*]] = frem float [[A]], 3.000000e+00
22+
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x float> poison, float [[TMP1]], i64 1
23+
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[CMP]], <2 x float> <float 7.700000e+01, float 9.900000e+01>, <2 x float> [[TMP2]]
24+
; CHECK-NEXT: ret <2 x float> [[TMP3]]
25+
;
26+
%1 = frem float %a, 3.000000e+00
27+
%2 = insertelement <2 x float> poison, float %1, i64 1
28+
%3 = select i1 %cmp, <2 x float> <float 7.700000e+01, float 9.900000e+01>, <2 x float> %2
29+
ret <2 x float> %3
30+
}
31+
32+
define <2 x float> @replace_through_casts(i16 %inp) {
33+
; CHECK-LABEL: define <2 x float> @replace_through_casts(
34+
; CHECK-SAME: i16 [[INP:%.*]]) {
35+
; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
36+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i16> poison, i16 [[INP]], i32 0
37+
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x i16> [[TMP1]], i16 [[ADD]], i32 1
38+
; CHECK-NEXT: [[TMP3:%.*]] = uitofp <2 x i16> [[TMP2]] to <2 x float>
39+
; CHECK-NEXT: [[TMP4:%.*]] = sitofp <2 x i16> [[TMP2]] to <2 x float>
40+
; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x float> [[TMP3]], <2 x float> [[TMP4]], <2 x i32> <i32 0, i32 3>
41+
; CHECK-NEXT: ret <2 x float> [[R]]
42+
;
43+
%add = add nsw i16 %inp, -10
44+
%1 = uitofp i16 %inp to float
45+
%2 = sitofp i16 %add to float
46+
%3 = insertelement <2 x float> poison, float %1, i64 0
47+
%r = insertelement <2 x float> %3, float %2, i64 1
48+
ret <2 x float> %r
49+
}
50+
51+
define <2 x float> @replace_through_casts_and_binop(i16 %inp) {
52+
; CHECK-LABEL: define <2 x float> @replace_through_casts_and_binop(
53+
; CHECK-SAME: i16 [[INP:%.*]]) {
54+
; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
55+
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i16 [[INP]], 5
56+
; CHECK-NEXT: [[TMP1:%.*]] = uitofp i16 [[MUL]] to float
57+
; CHECK-NEXT: [[TMP2:%.*]] = fadd float [[TMP1]], 2.000000e+00
58+
; CHECK-NEXT: [[TMP3:%.*]] = sitofp i16 [[ADD]] to float
59+
; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x float> poison, float [[TMP2]], i64 0
60+
; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[TMP4]], float [[TMP3]], i64 1
61+
; CHECK-NEXT: ret <2 x float> [[R]]
62+
;
63+
%add = add nsw i16 %inp, -10
64+
%mul = mul nsw i16 %inp, 5
65+
%1 = uitofp i16 %mul to float
66+
%2 = fadd float %1, 2.000000e+00
67+
%3 = sitofp i16 %add to float
68+
%4 = insertelement <2 x float> poison, float %2, i64 0
69+
%r = insertelement <2 x float> %4, float %3, i64 1
70+
ret <2 x float> %r
71+
}
72+
73+
define <2 x float> @replace_through_casts_and_binop_and_unop(i16 %inp) {
74+
; CHECK-LABEL: define <2 x float> @replace_through_casts_and_binop_and_unop(
75+
; CHECK-SAME: i16 [[INP:%.*]]) {
76+
; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
77+
; CHECK-NEXT: [[TMP1:%.*]] = sitofp i16 [[ADD]] to float
78+
; CHECK-NEXT: [[TMP2:%.*]] = fneg float [[TMP1]]
79+
; CHECK-NEXT: [[TMP3:%.*]] = uitofp i16 [[ADD]] to float
80+
; CHECK-NEXT: [[TMP4:%.*]] = fadd float [[TMP3]], 2.000000e+00
81+
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x float> poison, float [[TMP4]], i64 0
82+
; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[TMP5]], float [[TMP2]], i64 1
83+
; CHECK-NEXT: ret <2 x float> [[R]]
84+
;
85+
%add = add nsw i16 %inp, -10
86+
%1 = sitofp i16 %add to float
87+
%2 = fneg float %1
88+
%3 = uitofp i16 %add to float
89+
%4 = fadd float %3, 2.000000e+00
90+
%5 = insertelement <2 x float> poison, float %4, i64 0
91+
%r = insertelement <2 x float> %5, float %2, i64 1
92+
ret <2 x float> %r
93+
}
94+
95+
define <2 x float> @replace_through_casts_through_splat(i16 %inp) {
96+
; CHECK-LABEL: define <2 x float> @replace_through_casts_through_splat(
97+
; CHECK-SAME: i16 [[INP:%.*]]) {
98+
; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
99+
; CHECK-NEXT: [[TMP1:%.*]] = uitofp i16 [[ADD]] to float
100+
; CHECK-NEXT: [[TMP2:%.*]] = fadd float [[TMP1]], 2.000000e+00
101+
; CHECK-NEXT: [[TMP3:%.*]] = sitofp i16 [[ADD]] to float
102+
; CHECK-NEXT: [[TMP4:%.*]] = fneg float [[TMP3]]
103+
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x float> poison, float [[TMP2]], i64 0
104+
; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[TMP5]], float [[TMP4]], i64 1
105+
; CHECK-NEXT: ret <2 x float> [[R]]
106+
;
107+
%add = add nsw i16 %inp, -10
108+
%1 = uitofp i16 %add to float
109+
%2 = fadd float %1, 2.000000e+00
110+
%3 = sitofp i16 %add to float
111+
%4 = fneg float %3
112+
%5 = insertelement <2 x float> poison, float %2, i64 0
113+
%r = insertelement <2 x float> %5, float %4, i64 1
114+
ret <2 x float> %r
115+
}
116+
117+
define <2 x i32> @replace_through_int_casts(i16 %inp, <2 x i16> %dead) {
118+
; CHECK-LABEL: define <2 x i32> @replace_through_int_casts(
119+
; CHECK-SAME: i16 [[INP:%.*]], <2 x i16> [[DEAD:%.*]]) {
120+
; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
121+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i16> poison, i16 [[INP]], i32 0
122+
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x i16> [[TMP1]], i16 [[ADD]], i32 1
123+
; CHECK-NEXT: [[TMP3:%.*]] = zext <2 x i16> [[TMP2]] to <2 x i32>
124+
; CHECK-NEXT: [[TMP4:%.*]] = sext <2 x i16> [[TMP2]] to <2 x i32>
125+
; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x i32> [[TMP3]], <2 x i32> [[TMP4]], <2 x i32> <i32 0, i32 3>
126+
; CHECK-NEXT: ret <2 x i32> [[R]]
127+
;
128+
%add = add nsw i16 %inp, -10
129+
%1 = zext i16 %inp to i32
130+
%2 = sext i16 %add to i32
131+
%3 = insertelement <2 x i32> poison, i32 %1, i64 0
132+
%r = insertelement <2 x i32> %3, i32 %2, i64 1
133+
ret <2 x i32> %r
134+
}
135+
136+
define <2 x i32> @replace_through_int_casts_ele0_only(i16 %inp, <2 x i16> %dead) {
137+
; CHECK-LABEL: define <2 x i32> @replace_through_int_casts_ele0_only(
138+
; CHECK-SAME: i16 [[INP:%.*]], <2 x i16> [[DEAD:%.*]]) {
139+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i16> poison, i16 [[INP]], i32 0
140+
; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <2 x i16> [[TMP1]], <2 x i16> poison, <2 x i32> zeroinitializer
141+
; CHECK-NEXT: [[TMP3:%.*]] = zext <2 x i16> [[TMP2]] to <2 x i32>
142+
; CHECK-NEXT: [[TMP4:%.*]] = sext <2 x i16> [[TMP2]] to <2 x i32>
143+
; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x i32> [[TMP3]], <2 x i32> [[TMP4]], <2 x i32> <i32 0, i32 3>
144+
; CHECK-NEXT: ret <2 x i32> [[R]]
145+
;
146+
%2 = sext i16 %inp to i32
147+
%4 = zext i16 %inp to i32
148+
%5 = insertelement <2 x i32> poison, i32 %4, i64 0
149+
%r = insertelement <2 x i32> %5, i32 %2, i64 1
150+
ret <2 x i32> %r
151+
}
152+
153+
define <2 x i8> @replace_through_binop_fail_cant_speculate(i8 %inp, <2 x i8> %d, <2 x i8> %any) {
154+
; CHECK-LABEL: define <2 x i8> @replace_through_binop_fail_cant_speculate(
155+
; CHECK-SAME: i8 [[INP:%.*]], <2 x i8> [[D:%.*]], <2 x i8> [[ANY:%.*]]) {
156+
; CHECK-NEXT: [[ADD:%.*]] = add i8 [[INP]], 5
157+
; CHECK-NEXT: [[V0:%.*]] = insertelement <2 x i8> poison, i8 [[INP]], i64 0
158+
; CHECK-NEXT: [[V:%.*]] = insertelement <2 x i8> [[V0]], i8 [[ADD]], i64 1
159+
; CHECK-NEXT: [[DIV0:%.*]] = sdiv <2 x i8> <i8 -128, i8 -128>, [[V]]
160+
; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[INP]], 123
161+
; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i8> [[DIV0]], i8 [[TMP1]], i64 0
162+
; CHECK-NEXT: ret <2 x i8> [[R]]
163+
;
164+
%add = add i8 %inp, 5
165+
%v0 = insertelement <2 x i8> poison, i8 %inp, i64 0
166+
%v = insertelement <2 x i8> %v0, i8 %add, i64 1
167+
%div0 = sdiv <2 x i8> <i8 -128, i8 -128>, %v
168+
%1 = xor i8 %inp, 123
169+
%r = insertelement <2 x i8> %div0, i8 %1, i64 0
170+
ret <2 x i8> %r
171+
}
172+
173+
define <2 x i8> @replace_through_binop_preserve_flags(i8 %inp, <2 x i8> %d, <2 x i8> %any) {
174+
; CHECK-LABEL: define <2 x i8> @replace_through_binop_preserve_flags(
175+
; CHECK-SAME: i8 [[INP:%.*]], <2 x i8> [[D:%.*]], <2 x i8> [[ANY:%.*]]) {
176+
; CHECK-NEXT: [[ADD:%.*]] = xor i8 [[INP]], 5
177+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i8> poison, i8 [[INP]], i32 0
178+
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x i8> [[TMP1]], i8 [[ADD]], i32 1
179+
; CHECK-NEXT: [[TMP3:%.*]] = xor <2 x i8> [[TMP2]], <i8 123, i8 1>
180+
; CHECK-NEXT: [[TMP4:%.*]] = add nsw <2 x i8> [[TMP2]], <i8 123, i8 1>
181+
; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x i8> [[TMP3]], <2 x i8> [[TMP4]], <2 x i32> <i32 0, i32 3>
182+
; CHECK-NEXT: ret <2 x i8> [[R]]
183+
;
184+
%add = xor i8 %inp, 5
185+
%1 = xor i8 %inp, 123
186+
%2 = add nsw i8 %add, 1
187+
%3 = insertelement <2 x i8> poison, i8 %1, i64 0
188+
%r = insertelement <2 x i8> %3, i8 %2, i64 1
189+
ret <2 x i8> %r
190+
}

0 commit comments

Comments
 (0)