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
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]]
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
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]]
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
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:%.*]] = uitofp i16 [[INP]] to float
37 ; CHECK-NEXT: [[TMP2:%.*]] = sitofp i16 [[ADD]] to float
38 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x float> poison, float [[TMP1]], i64 0
39 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[TMP3]], float [[TMP2]], i64 1
40 ; CHECK-NEXT: ret <2 x float> [[R]]
42 %add = add nsw i16 %inp, -10
43 %1 = uitofp i16 %inp to float
44 %2 = sitofp i16 %add to float
45 %3 = insertelement <2 x float> poison, float %1, i64 0
46 %r = insertelement <2 x float> %3, float %2, i64 1
50 define <2 x float> @replace_through_casts_and_binop(i16 %inp) {
51 ; CHECK-LABEL: define <2 x float> @replace_through_casts_and_binop(
52 ; CHECK-SAME: i16 [[INP:%.*]]) {
53 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
54 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i16 [[INP]], 5
55 ; CHECK-NEXT: [[TMP1:%.*]] = uitofp i16 [[MUL]] to float
56 ; CHECK-NEXT: [[TMP2:%.*]] = fadd float [[TMP1]], 2.000000e+00
57 ; CHECK-NEXT: [[TMP3:%.*]] = sitofp i16 [[ADD]] to float
58 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x float> poison, float [[TMP2]], i64 0
59 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[TMP4]], float [[TMP3]], i64 1
60 ; CHECK-NEXT: ret <2 x float> [[R]]
62 %add = add nsw i16 %inp, -10
63 %mul = mul nsw i16 %inp, 5
64 %1 = uitofp i16 %mul to float
65 %2 = fadd float %1, 2.000000e+00
66 %3 = sitofp i16 %add to float
67 %4 = insertelement <2 x float> poison, float %2, i64 0
68 %r = insertelement <2 x float> %4, float %3, i64 1
72 define <2 x float> @replace_through_casts_and_binop_and_unop(i16 %inp) {
73 ; CHECK-LABEL: define <2 x float> @replace_through_casts_and_binop_and_unop(
74 ; CHECK-SAME: i16 [[INP:%.*]]) {
75 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
76 ; CHECK-NEXT: [[TMP1:%.*]] = sitofp i16 [[ADD]] to float
77 ; CHECK-NEXT: [[TMP2:%.*]] = fneg float [[TMP1]]
78 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i16 [[ADD]] to float
79 ; CHECK-NEXT: [[TMP4:%.*]] = fadd float [[TMP3]], 2.000000e+00
80 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x float> poison, float [[TMP4]], i64 0
81 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[TMP5]], float [[TMP2]], i64 1
82 ; CHECK-NEXT: ret <2 x float> [[R]]
84 %add = add nsw i16 %inp, -10
85 %1 = sitofp i16 %add to float
87 %3 = uitofp i16 %add to float
88 %4 = fadd float %3, 2.000000e+00
89 %5 = insertelement <2 x float> poison, float %4, i64 0
90 %r = insertelement <2 x float> %5, float %2, i64 1
94 define <2 x float> @replace_through_casts_through_splat(i16 %inp) {
95 ; CHECK-LABEL: define <2 x float> @replace_through_casts_through_splat(
96 ; CHECK-SAME: i16 [[INP:%.*]]) {
97 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
98 ; CHECK-NEXT: [[TMP1:%.*]] = uitofp i16 [[ADD]] to float
99 ; CHECK-NEXT: [[TMP2:%.*]] = fadd float [[TMP1]], 2.000000e+00
100 ; CHECK-NEXT: [[TMP3:%.*]] = sitofp i16 [[ADD]] to float
101 ; CHECK-NEXT: [[TMP4:%.*]] = fneg float [[TMP3]]
102 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x float> poison, float [[TMP2]], i64 0
103 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[TMP5]], float [[TMP4]], i64 1
104 ; CHECK-NEXT: ret <2 x float> [[R]]
106 %add = add nsw i16 %inp, -10
107 %1 = uitofp i16 %add to float
108 %2 = fadd float %1, 2.000000e+00
109 %3 = sitofp i16 %add to float
111 %5 = insertelement <2 x float> poison, float %2, i64 0
112 %r = insertelement <2 x float> %5, float %4, i64 1
116 define <2 x i32> @replace_through_int_casts(i16 %inp, <2 x i16> %dead) {
117 ; CHECK-LABEL: define <2 x i32> @replace_through_int_casts(
118 ; CHECK-SAME: i16 [[INP:%.*]], <2 x i16> [[DEAD:%.*]]) {
119 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[INP]], -10
120 ; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[INP]] to i32
121 ; CHECK-NEXT: [[TMP2:%.*]] = sext i16 [[ADD]] to i32
122 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP1]], i64 0
123 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP2]], i64 1
124 ; CHECK-NEXT: ret <2 x i32> [[R]]
126 %add = add nsw i16 %inp, -10
127 %1 = zext i16 %inp to i32
128 %2 = sext i16 %add to i32
129 %3 = insertelement <2 x i32> poison, i32 %1, i64 0
130 %r = insertelement <2 x i32> %3, i32 %2, i64 1
134 define <2 x i32> @replace_through_int_casts_ele0_only(i16 %inp, <2 x i16> %dead) {
135 ; CHECK-LABEL: define <2 x i32> @replace_through_int_casts_ele0_only(
136 ; CHECK-SAME: i16 [[INP:%.*]], <2 x i16> [[DEAD:%.*]]) {
137 ; CHECK-NEXT: [[TMP1:%.*]] = sext i16 [[INP]] to i32
138 ; CHECK-NEXT: [[TMP2:%.*]] = zext i16 [[INP]] to i32
139 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i64 0
140 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP1]], i64 1
141 ; CHECK-NEXT: ret <2 x i32> [[R]]
143 %2 = sext i16 %inp to i32
144 %4 = zext i16 %inp to i32
145 %5 = insertelement <2 x i32> poison, i32 %4, i64 0
146 %r = insertelement <2 x i32> %5, i32 %2, i64 1
150 define <2 x i8> @replace_through_binop_fail_cant_speculate(i8 %inp, <2 x i8> %d, <2 x i8> %any) {
151 ; CHECK-LABEL: define <2 x i8> @replace_through_binop_fail_cant_speculate(
152 ; CHECK-SAME: i8 [[INP:%.*]], <2 x i8> [[D:%.*]], <2 x i8> [[ANY:%.*]]) {
153 ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[INP]], 5
154 ; CHECK-NEXT: [[V0:%.*]] = insertelement <2 x i8> poison, i8 [[INP]], i64 0
155 ; CHECK-NEXT: [[V:%.*]] = insertelement <2 x i8> [[V0]], i8 [[ADD]], i64 1
156 ; CHECK-NEXT: [[DIV0:%.*]] = sdiv <2 x i8> splat (i8 -128), [[V]]
157 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[INP]], 123
158 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i8> [[DIV0]], i8 [[TMP1]], i64 0
159 ; CHECK-NEXT: ret <2 x i8> [[R]]
161 %add = add i8 %inp, 5
162 %v0 = insertelement <2 x i8> poison, i8 %inp, i64 0
163 %v = insertelement <2 x i8> %v0, i8 %add, i64 1
164 %div0 = sdiv <2 x i8> <i8 -128, i8 -128>, %v
165 %1 = xor i8 %inp, 123
166 %r = insertelement <2 x i8> %div0, i8 %1, i64 0
170 define <2 x i8> @replace_through_binop_preserve_flags(i8 %inp, <2 x i8> %d, <2 x i8> %any) {
171 ; CHECK-LABEL: define <2 x i8> @replace_through_binop_preserve_flags(
172 ; CHECK-SAME: i8 [[INP:%.*]], <2 x i8> [[D:%.*]], <2 x i8> [[ANY:%.*]]) {
173 ; CHECK-NEXT: [[ADD:%.*]] = xor i8 [[INP]], 5
174 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[INP]], 123
175 ; CHECK-NEXT: [[TMP2:%.*]] = add nsw i8 [[ADD]], 1
176 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i8> poison, i8 [[TMP1]], i64 0
177 ; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i8> [[TMP3]], i8 [[TMP2]], i64 1
178 ; CHECK-NEXT: ret <2 x i8> [[R]]
180 %add = xor i8 %inp, 5
181 %1 = xor i8 %inp, 123
182 %2 = add nsw i8 %add, 1
183 %3 = insertelement <2 x i8> poison, i8 %1, i64 0
184 %r = insertelement <2 x i8> %3, i8 %2, i64 1