1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
3 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
4 ; RUN: --check-prefixes=CHECK,CHECK-LE
5 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
6 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
7 ; RUN: --check-prefixes=CHECK,CHECK-BE
9 ; This file does not contain many test cases involving comparisons and logical
10 ; comparisons (cmplwi, cmpldi). This is because alternative code is generated
11 ; when there is a compare (logical or not), followed by a sign or zero extend.
12 ; This codegen will be re-evaluated at a later time on whether or not it should
15 @globalVal = common dso_local local_unnamed_addr global i8 0, align 1
16 @globalVal2 = common dso_local local_unnamed_addr global i32 0, align 4
17 @globalVal3 = common dso_local local_unnamed_addr global i64 0, align 8
18 @globalVal4 = common dso_local local_unnamed_addr global i16 0, align 2
20 define dso_local signext i32 @setnbcr1(i8 %a) {
21 ; CHECK-LABEL: setnbcr1:
22 ; CHECK: # %bb.0: # %entry
23 ; CHECK-NEXT: andi. r3, r3, 255
24 ; CHECK-NEXT: setnbcr r3, eq
27 %cmp = icmp uge i8 %a, 1
28 %conv = sext i1 %cmp to i32
32 define dso_local signext i32 @setnbcr2(i32 %a) {
33 ; CHECK-LABEL: setnbcr2:
34 ; CHECK: # %bb.0: # %entry
35 ; CHECK-NEXT: cmpwi r3, 0
36 ; CHECK-NEXT: setnbcr r3, eq
39 %cmp = icmp uge i32 %a, 1
40 %conv = sext i1 %cmp to i32
44 define dso_local signext i32 @setnbcr3(i64 %a) {
45 ; CHECK-LABEL: setnbcr3:
46 ; CHECK: # %bb.0: # %entry
47 ; CHECK-NEXT: cmpdi r3, 0
48 ; CHECK-NEXT: setnbcr r3, eq
51 %cmp = icmp uge i64 %a, 1
52 %conv = sext i1 %cmp to i32
56 define dso_local signext i32 @setnbcr4(i16 %a) {
57 ; CHECK-LABEL: setnbcr4:
58 ; CHECK: # %bb.0: # %entry
59 ; CHECK-NEXT: andi. r3, r3, 65535
60 ; CHECK-NEXT: setnbcr r3, eq
63 %cmp = icmp uge i16 %a, 1
64 %conv = sext i1 %cmp to i32
68 define signext i64 @setnbcr5(i8 %a) {
69 ; CHECK-LABEL: setnbcr5:
70 ; CHECK: # %bb.0: # %entry
71 ; CHECK-NEXT: andi. r3, r3, 255
72 ; CHECK-NEXT: setnbcr r3, eq
75 %cmp = icmp uge i8 %a, 1
76 %conv = sext i1 %cmp to i64
80 define signext i64 @setnbcr6(i32 %a) {
81 ; CHECK-LABEL: setnbcr6:
82 ; CHECK: # %bb.0: # %entry
83 ; CHECK-NEXT: cmpwi r3, 0
84 ; CHECK-NEXT: setnbcr r3, eq
87 %cmp = icmp uge i32 %a, 1
88 %conv = sext i1 %cmp to i64
92 define signext i64 @setnbcr7(i64 %a) {
93 ; CHECK-LABEL: setnbcr7:
94 ; CHECK: # %bb.0: # %entry
95 ; CHECK-NEXT: cmpdi r3, 0
96 ; CHECK-NEXT: setnbcr r3, eq
99 %cmp = icmp uge i64 %a, 1
100 %conv = sext i1 %cmp to i64
104 define signext i64 @setnbcr8(i16 %a) {
105 ; CHECK-LABEL: setnbcr8:
106 ; CHECK: # %bb.0: # %entry
107 ; CHECK-NEXT: andi. r3, r3, 65535
108 ; CHECK-NEXT: setnbcr r3, eq
111 %cmp = icmp uge i16 %a, 1
112 %conv = sext i1 %cmp to i64
116 define dso_local void @setnbcr9(i8 %a) {
117 ; CHECK-LE-LABEL: setnbcr9:
118 ; CHECK-LE: # %bb.0: # %entry
119 ; CHECK-LE-NEXT: andi. r3, r3, 255
120 ; CHECK-LE-NEXT: setnbcr r3, eq
121 ; CHECK-LE-NEXT: pstb r3, globalVal@PCREL(0), 1
124 ; CHECK-BE-LABEL: setnbcr9:
125 ; CHECK-BE: # %bb.0: # %entry
126 ; CHECK-BE-NEXT: andi. r3, r3, 255
127 ; CHECK-BE-NEXT: addis r4, r2, globalVal@toc@ha
128 ; CHECK-BE-NEXT: setnbcr r3, eq
129 ; CHECK-BE-NEXT: stb r3, globalVal@toc@l(r4)
132 %cmp = icmp uge i8 %a, 1
133 %conv1 = sext i1 %cmp to i8
134 store i8 %conv1, i8* @globalVal, align 1
138 define dso_local void @setnbcr10(i32 %a) {
139 ; CHECK-LE-LABEL: setnbcr10:
140 ; CHECK-LE: # %bb.0: # %entry
141 ; CHECK-LE-NEXT: cmpwi r3, 0
142 ; CHECK-LE-NEXT: setnbcr r3, eq
143 ; CHECK-LE-NEXT: pstw r3, globalVal2@PCREL(0), 1
146 ; CHECK-BE-LABEL: setnbcr10:
147 ; CHECK-BE: # %bb.0: # %entry
148 ; CHECK-BE-NEXT: cmpwi r3, 0
149 ; CHECK-BE-NEXT: addis r4, r2, globalVal2@toc@ha
150 ; CHECK-BE-NEXT: setnbcr r3, eq
151 ; CHECK-BE-NEXT: stw r3, globalVal2@toc@l(r4)
154 %cmp = icmp uge i32 %a, 1
155 %conv1 = sext i1 %cmp to i32
156 store i32 %conv1, i32* @globalVal2, align 4
160 define dso_local void @setnbcr11(i64 %a) {
161 ; CHECK-LE-LABEL: setnbcr11:
162 ; CHECK-LE: # %bb.0: # %entry
163 ; CHECK-LE-NEXT: cmpdi r3, 0
164 ; CHECK-LE-NEXT: setnbcr r3, eq
165 ; CHECK-LE-NEXT: pstd r3, globalVal3@PCREL(0), 1
168 ; CHECK-BE-LABEL: setnbcr11:
169 ; CHECK-BE: # %bb.0: # %entry
170 ; CHECK-BE-NEXT: cmpdi r3, 0
171 ; CHECK-BE-NEXT: addis r4, r2, globalVal3@toc@ha
172 ; CHECK-BE-NEXT: setnbcr r3, eq
173 ; CHECK-BE-NEXT: std r3, globalVal3@toc@l(r4)
176 %cmp = icmp uge i64 %a, 1
177 %conv1 = sext i1 %cmp to i64
178 store i64 %conv1, i64* @globalVal3, align 8
182 define dso_local void @setnbcr12(i16 %a) {
183 ; CHECK-LE-LABEL: setnbcr12:
184 ; CHECK-LE: # %bb.0: # %entry
185 ; CHECK-LE-NEXT: andi. r3, r3, 65535
186 ; CHECK-LE-NEXT: setnbcr r3, eq
187 ; CHECK-LE-NEXT: psth r3, globalVal4@PCREL(0), 1
190 ; CHECK-BE-LABEL: setnbcr12:
191 ; CHECK-BE: # %bb.0: # %entry
192 ; CHECK-BE-NEXT: andi. r3, r3, 65535
193 ; CHECK-BE-NEXT: addis r4, r2, globalVal4@toc@ha
194 ; CHECK-BE-NEXT: setnbcr r3, eq
195 ; CHECK-BE-NEXT: sth r3, globalVal4@toc@l(r4)
198 %cmp = icmp uge i16 %a, 1
199 %conv1 = sext i1 %cmp to i16
200 store i16 %conv1, i16* @globalVal4, align 2
204 define dso_local signext i32 @setnbcr13(i8 %a) {
205 ; CHECK-LABEL: setnbcr13:
206 ; CHECK: # %bb.0: # %entry
207 ; CHECK-NEXT: clrlwi r3, r3, 24
208 ; CHECK-NEXT: cmpwi r3, 1
209 ; CHECK-NEXT: setnbcr r3, eq
212 %cmp = icmp ne i8 %a, 1
213 %conv = sext i1 %cmp to i32
217 define dso_local signext i32 @setnbcr14(i32 %a) {
218 ; CHECK-LABEL: setnbcr14:
219 ; CHECK: # %bb.0: # %entry
220 ; CHECK-NEXT: cmpwi r3, 1
221 ; CHECK-NEXT: setnbcr r3, eq
224 %cmp = icmp ne i32 %a, 1
225 %conv = sext i1 %cmp to i32
229 define dso_local signext i32 @setnbcr15(i64 %a) {
230 ; CHECK-LABEL: setnbcr15:
231 ; CHECK: # %bb.0: # %entry
232 ; CHECK-NEXT: cmpdi r3, 1
233 ; CHECK-NEXT: setnbcr r3, eq
236 %cmp = icmp ne i64 %a, 1
237 %conv = sext i1 %cmp to i32
241 define dso_local signext i32 @setnbcr16(i16 %a) {
242 ; CHECK-LABEL: setnbcr16:
243 ; CHECK: # %bb.0: # %entry
244 ; CHECK-NEXT: clrlwi r3, r3, 16
245 ; CHECK-NEXT: cmpwi r3, 1
246 ; CHECK-NEXT: setnbcr r3, eq
249 %cmp = icmp ne i16 %a, 1
250 %conv = sext i1 %cmp to i32
254 define signext i64 @setnbcr17(i8 %a) {
255 ; CHECK-LABEL: setnbcr17:
256 ; CHECK: # %bb.0: # %entry
257 ; CHECK-NEXT: clrlwi r3, r3, 24
258 ; CHECK-NEXT: cmpwi r3, 1
259 ; CHECK-NEXT: setnbcr r3, eq
262 %cmp = icmp ne i8 %a, 1
263 %conv = sext i1 %cmp to i64
267 define signext i64 @setnbcr18(i32 %a) {
268 ; CHECK-LABEL: setnbcr18:
269 ; CHECK: # %bb.0: # %entry
270 ; CHECK-NEXT: cmpwi r3, 1
271 ; CHECK-NEXT: setnbcr r3, eq
274 %cmp = icmp ne i32 %a, 1
275 %conv = sext i1 %cmp to i64
279 define signext i64 @setnbcr19(i64 %a) {
280 ; CHECK-LABEL: setnbcr19:
281 ; CHECK: # %bb.0: # %entry
282 ; CHECK-NEXT: cmpdi r3, 1
283 ; CHECK-NEXT: setnbcr r3, eq
286 %cmp = icmp ne i64 %a, 1
287 %conv = sext i1 %cmp to i64
291 define signext i64 @setnbcr20(i16 %a) {
292 ; CHECK-LABEL: setnbcr20:
293 ; CHECK: # %bb.0: # %entry
294 ; CHECK-NEXT: clrlwi r3, r3, 16
295 ; CHECK-NEXT: cmpwi r3, 1
296 ; CHECK-NEXT: setnbcr r3, eq
299 %cmp = icmp ne i16 %a, 1
300 %conv = sext i1 %cmp to i64
304 define dso_local void @setnbcr21(i8 %a) {
305 ; CHECK-LE-LABEL: setnbcr21:
306 ; CHECK-LE: # %bb.0: # %entry
307 ; CHECK-LE-NEXT: clrlwi r3, r3, 24
308 ; CHECK-LE-NEXT: cmpwi r3, 1
309 ; CHECK-LE-NEXT: setnbcr r3, eq
310 ; CHECK-LE-NEXT: pstb r3, globalVal@PCREL(0), 1
313 ; CHECK-BE-LABEL: setnbcr21:
314 ; CHECK-BE: # %bb.0: # %entry
315 ; CHECK-BE-NEXT: clrlwi r3, r3, 24
316 ; CHECK-BE-NEXT: addis r4, r2, globalVal@toc@ha
317 ; CHECK-BE-NEXT: cmpwi r3, 1
318 ; CHECK-BE-NEXT: setnbcr r3, eq
319 ; CHECK-BE-NEXT: stb r3, globalVal@toc@l(r4)
322 %cmp = icmp ne i8 %a, 1
323 %conv1 = sext i1 %cmp to i8
324 store i8 %conv1, i8* @globalVal, align 1
328 define dso_local void @setnbcr22(i32 %a) {
329 ; CHECK-LE-LABEL: setnbcr22:
330 ; CHECK-LE: # %bb.0: # %entry
331 ; CHECK-LE-NEXT: cmpwi r3, 1
332 ; CHECK-LE-NEXT: setnbcr r3, eq
333 ; CHECK-LE-NEXT: pstw r3, globalVal2@PCREL(0), 1
336 ; CHECK-BE-LABEL: setnbcr22:
337 ; CHECK-BE: # %bb.0: # %entry
338 ; CHECK-BE-NEXT: cmpwi r3, 1
339 ; CHECK-BE-NEXT: addis r4, r2, globalVal2@toc@ha
340 ; CHECK-BE-NEXT: setnbcr r3, eq
341 ; CHECK-BE-NEXT: stw r3, globalVal2@toc@l(r4)
344 %cmp = icmp ne i32 %a, 1
345 %conv1 = sext i1 %cmp to i32
346 store i32 %conv1, i32* @globalVal2, align 4
350 define dso_local void @setnbcr23(i64 %a) {
351 ; CHECK-LE-LABEL: setnbcr23:
352 ; CHECK-LE: # %bb.0: # %entry
353 ; CHECK-LE-NEXT: cmpdi r3, 1
354 ; CHECK-LE-NEXT: setnbcr r3, eq
355 ; CHECK-LE-NEXT: pstd r3, globalVal3@PCREL(0), 1
358 ; CHECK-BE-LABEL: setnbcr23:
359 ; CHECK-BE: # %bb.0: # %entry
360 ; CHECK-BE-NEXT: cmpdi r3, 1
361 ; CHECK-BE-NEXT: addis r4, r2, globalVal3@toc@ha
362 ; CHECK-BE-NEXT: setnbcr r3, eq
363 ; CHECK-BE-NEXT: std r3, globalVal3@toc@l(r4)
366 %cmp = icmp ne i64 %a, 1
367 %conv1 = sext i1 %cmp to i64
368 store i64 %conv1, i64* @globalVal3, align 8
372 define dso_local void @setnbcr24(i16 %a) {
373 ; CHECK-LE-LABEL: setnbcr24:
374 ; CHECK-LE: # %bb.0: # %entry
375 ; CHECK-LE-NEXT: clrlwi r3, r3, 16
376 ; CHECK-LE-NEXT: cmpwi r3, 1
377 ; CHECK-LE-NEXT: setnbcr r3, eq
378 ; CHECK-LE-NEXT: psth r3, globalVal4@PCREL(0), 1
381 ; CHECK-BE-LABEL: setnbcr24:
382 ; CHECK-BE: # %bb.0: # %entry
383 ; CHECK-BE-NEXT: clrlwi r3, r3, 16
384 ; CHECK-BE-NEXT: addis r4, r2, globalVal4@toc@ha
385 ; CHECK-BE-NEXT: cmpwi r3, 1
386 ; CHECK-BE-NEXT: setnbcr r3, eq
387 ; CHECK-BE-NEXT: sth r3, globalVal4@toc@l(r4)
390 %cmp = icmp ne i16 %a, 1
391 %conv1 = sext i1 %cmp to i16
392 store i16 %conv1, i16* @globalVal4, align 2