1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=powerpc64le-- | FileCheck %s
6 define i32 @zext_ifpos(i32 %x) {
7 ; CHECK-LABEL: zext_ifpos:
9 ; CHECK-NEXT: rlwinm 3, 3, 1, 31, 31
10 ; CHECK-NEXT: xori 3, 3, 1
12 %c = icmp sgt i32 %x, -1
13 %e = zext i1 %c to i32
17 define i32 @add_zext_ifpos(i32 %x) {
18 ; CHECK-LABEL: add_zext_ifpos:
20 ; CHECK-NEXT: srawi 3, 3, 31
21 ; CHECK-NEXT: addi 3, 3, 42
23 %c = icmp sgt i32 %x, -1
24 %e = zext i1 %c to i32
29 define <4 x i32> @add_zext_ifpos_vec_splat(<4 x i32> %x) {
30 ; CHECK-LABEL: add_zext_ifpos_vec_splat:
32 ; CHECK-NEXT: addis 3, 2, .LCPI2_0@toc@ha
33 ; CHECK-NEXT: xxleqv 35, 35, 35
34 ; CHECK-NEXT: vcmpgtsw 2, 2, 3
35 ; CHECK-NEXT: addi 3, 3, .LCPI2_0@toc@l
36 ; CHECK-NEXT: lxvd2x 35, 0, 3
37 ; CHECK-NEXT: vsubuwm 2, 3, 2
39 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
40 %e = zext <4 x i1> %c to <4 x i32>
41 %r = add <4 x i32> %e, <i32 41, i32 41, i32 41, i32 41>
45 define i32 @sel_ifpos_tval_bigger(i32 %x) {
46 ; CHECK-LABEL: sel_ifpos_tval_bigger:
48 ; CHECK-NEXT: rlwinm 3, 3, 1, 31, 31
49 ; CHECK-NEXT: xori 3, 3, 1
50 ; CHECK-NEXT: addi 3, 3, 41
52 %c = icmp sgt i32 %x, -1
53 %r = select i1 %c, i32 42, i32 41
57 define i32 @sext_ifpos(i32 %x) {
58 ; CHECK-LABEL: sext_ifpos:
60 ; CHECK-NEXT: not 3, 3
61 ; CHECK-NEXT: srawi 3, 3, 31
63 %c = icmp sgt i32 %x, -1
64 %e = sext i1 %c to i32
68 define i32 @add_sext_ifpos(i32 %x) {
69 ; CHECK-LABEL: add_sext_ifpos:
71 ; CHECK-NEXT: srwi 3, 3, 31
72 ; CHECK-NEXT: addi 3, 3, 41
74 %c = icmp sgt i32 %x, -1
75 %e = sext i1 %c to i32
80 define <4 x i32> @add_sext_ifpos_vec_splat(<4 x i32> %x) {
81 ; CHECK-LABEL: add_sext_ifpos_vec_splat:
83 ; CHECK-NEXT: addis 3, 2, .LCPI6_0@toc@ha
84 ; CHECK-NEXT: xxleqv 35, 35, 35
85 ; CHECK-NEXT: vcmpgtsw 2, 2, 3
86 ; CHECK-NEXT: addi 3, 3, .LCPI6_0@toc@l
87 ; CHECK-NEXT: lxvd2x 35, 0, 3
88 ; CHECK-NEXT: vadduwm 2, 2, 3
90 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
91 %e = sext <4 x i1> %c to <4 x i32>
92 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
96 define i32 @sel_ifpos_fval_bigger(i32 %x) {
97 ; CHECK-LABEL: sel_ifpos_fval_bigger:
99 ; CHECK-NEXT: rlwinm 3, 3, 1, 31, 31
100 ; CHECK-NEXT: xori 3, 3, 1
101 ; CHECK-NEXT: subfic 3, 3, 42
103 %c = icmp sgt i32 %x, -1
104 %r = select i1 %c, i32 41, i32 42
110 define i32 @zext_ifneg(i32 %x) {
111 ; CHECK-LABEL: zext_ifneg:
113 ; CHECK-NEXT: rlwinm 3, 3, 1, 31, 31
115 %c = icmp slt i32 %x, 0
116 %r = zext i1 %c to i32
120 define i32 @add_zext_ifneg(i32 %x) {
121 ; CHECK-LABEL: add_zext_ifneg:
123 ; CHECK-NEXT: srwi 3, 3, 31
124 ; CHECK-NEXT: addi 3, 3, 41
126 %c = icmp slt i32 %x, 0
127 %e = zext i1 %c to i32
132 define i32 @sel_ifneg_tval_bigger(i32 %x) {
133 ; CHECK-LABEL: sel_ifneg_tval_bigger:
135 ; CHECK-NEXT: rlwinm 3, 3, 1, 31, 31
136 ; CHECK-NEXT: addi 3, 3, 41
138 %c = icmp slt i32 %x, 0
139 %r = select i1 %c, i32 42, i32 41
143 define i32 @sext_ifneg(i32 %x) {
144 ; CHECK-LABEL: sext_ifneg:
146 ; CHECK-NEXT: srawi 3, 3, 31
148 %c = icmp slt i32 %x, 0
149 %r = sext i1 %c to i32
153 define i32 @add_sext_ifneg(i32 %x) {
154 ; CHECK-LABEL: add_sext_ifneg:
156 ; CHECK-NEXT: srawi 3, 3, 31
157 ; CHECK-NEXT: addi 3, 3, 42
159 %c = icmp slt i32 %x, 0
160 %e = sext i1 %c to i32
165 define i32 @sel_ifneg_fval_bigger(i32 %x) {
166 ; CHECK-LABEL: sel_ifneg_fval_bigger:
168 ; CHECK-NEXT: rlwinm 3, 3, 1, 31, 31
169 ; CHECK-NEXT: subfic 3, 3, 42
171 %c = icmp slt i32 %x, 0
172 %r = select i1 %c, i32 41, i32 42
176 define i32 @add_lshr_not(i32 %x) {
177 ; CHECK-LABEL: add_lshr_not:
179 ; CHECK-NEXT: srawi 3, 3, 31
180 ; CHECK-NEXT: addi 3, 3, 42
182 %not = xor i32 %x, -1
183 %sh = lshr i32 %not, 31
188 define <4 x i32> @add_lshr_not_vec_splat(<4 x i32> %x) {
189 ; CHECK-LABEL: add_lshr_not_vec_splat:
191 ; CHECK-NEXT: vspltisw 3, -16
192 ; CHECK-NEXT: vspltisw 4, 15
193 ; CHECK-NEXT: addis 3, 2, .LCPI15_0@toc@ha
194 ; CHECK-NEXT: vsubuwm 3, 4, 3
195 ; CHECK-NEXT: addi 3, 3, .LCPI15_0@toc@l
196 ; CHECK-NEXT: vsraw 2, 2, 3
197 ; CHECK-NEXT: lxvd2x 35, 0, 3
198 ; CHECK-NEXT: vadduwm 2, 2, 3
200 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
201 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
202 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
206 define i32 @sub_lshr_not(i32 %x) {
207 ; CHECK-LABEL: sub_lshr_not:
209 ; CHECK-NEXT: srwi 3, 3, 31
210 ; CHECK-NEXT: ori 3, 3, 42
212 %not = xor i32 %x, -1
213 %sh = lshr i32 %not, 31
218 define <4 x i32> @sub_lshr_not_vec_splat(<4 x i32> %x) {
219 ; CHECK-LABEL: sub_lshr_not_vec_splat:
221 ; CHECK-NEXT: vspltisw 3, -16
222 ; CHECK-NEXT: vspltisw 4, 15
223 ; CHECK-NEXT: addis 3, 2, .LCPI17_0@toc@ha
224 ; CHECK-NEXT: vsubuwm 3, 4, 3
225 ; CHECK-NEXT: addi 3, 3, .LCPI17_0@toc@l
226 ; CHECK-NEXT: vsrw 2, 2, 3
227 ; CHECK-NEXT: lxvd2x 35, 0, 3
228 ; CHECK-NEXT: vadduwm 2, 2, 3
230 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
231 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
232 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %e
236 define i32 @sub_lshr(i32 %x, i32 %y) {
237 ; CHECK-LABEL: sub_lshr:
239 ; CHECK-NEXT: srawi 3, 3, 31
240 ; CHECK-NEXT: add 3, 4, 3
242 %sh = lshr i32 %x, 31
247 define <4 x i32> @sub_lshr_vec(<4 x i32> %x, <4 x i32> %y) {
248 ; CHECK-LABEL: sub_lshr_vec:
250 ; CHECK-NEXT: vspltisw 4, -16
251 ; CHECK-NEXT: vspltisw 5, 15
252 ; CHECK-NEXT: vsubuwm 4, 5, 4
253 ; CHECK-NEXT: vsraw 2, 2, 4
254 ; CHECK-NEXT: vadduwm 2, 3, 2
256 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
257 %r = sub <4 x i32> %y, %sh
261 define i32 @sub_const_op_lshr(i32 %x) {
262 ; CHECK-LABEL: sub_const_op_lshr:
264 ; CHECK-NEXT: srawi 3, 3, 31
265 ; CHECK-NEXT: addi 3, 3, 43
267 %sh = lshr i32 %x, 31
272 define <4 x i32> @sub_const_op_lshr_vec(<4 x i32> %x) {
273 ; CHECK-LABEL: sub_const_op_lshr_vec:
275 ; CHECK-NEXT: vspltisw 3, -16
276 ; CHECK-NEXT: vspltisw 4, 15
277 ; CHECK-NEXT: addis 3, 2, .LCPI21_0@toc@ha
278 ; CHECK-NEXT: vsubuwm 3, 4, 3
279 ; CHECK-NEXT: addi 3, 3, .LCPI21_0@toc@l
280 ; CHECK-NEXT: vsraw 2, 2, 3
281 ; CHECK-NEXT: lxvd2x 35, 0, 3
282 ; CHECK-NEXT: vadduwm 2, 2, 3
284 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
285 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %sh