1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -ppc-gpr-icmps=all -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -mattr=-crbits -disable-ppc-cmp-opt=0 | FileCheck %s
3 ; RUN: llc -ppc-gpr-icmps=all -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -mattr=-crbits -disable-ppc-cmp-opt=0 -ppc-gen-isel=false | FileCheck --check-prefix=CHECK-NO-ISEL %s
5 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
6 target triple = "powerpc64-unknown-linux-gnu"
8 define signext i32 @foo(i32 signext %a, i32 signext %b, ptr nocapture %c) #0 {
10 ; CHECK: # %bb.0: # %entry
11 ; CHECK-NEXT: cmpw 3, 4
12 ; CHECK-NEXT: sub 6, 3, 4
13 ; CHECK-NEXT: iselgt 3, 3, 4
14 ; CHECK-NEXT: stw 6, 0(5)
17 ; CHECK-NO-ISEL-LABEL: foo:
18 ; CHECK-NO-ISEL: # %bb.0: # %entry
19 ; CHECK-NO-ISEL-NEXT: cmpw 3, 4
20 ; CHECK-NO-ISEL-NEXT: sub 6, 3, 4
21 ; CHECK-NO-ISEL-NEXT: bc 12, 1, .LBB0_2
22 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
23 ; CHECK-NO-ISEL-NEXT: ori 3, 4, 0
24 ; CHECK-NO-ISEL-NEXT: b .LBB0_2
25 ; CHECK-NO-ISEL-NEXT: .LBB0_2: # %entry
26 ; CHECK-NO-ISEL-NEXT: stw 6, 0(5)
27 ; CHECK-NO-ISEL-NEXT: blr
29 %sub = sub nsw i32 %a, %b
30 store i32 %sub, ptr %c, align 4
31 %cmp = icmp sgt i32 %a, %b
32 %cond = select i1 %cmp, i32 %a, i32 %b
36 define signext i32 @foo2(i32 signext %a, i32 signext %b, ptr nocapture %c) #0 {
38 ; CHECK: # %bb.0: # %entry
39 ; CHECK-NEXT: slw 4, 3, 4
42 ; CHECK-NEXT: cmpwi 4, 0
43 ; CHECK-NEXT: stw 4, 0(5)
44 ; CHECK-NEXT: iselgt 3, 3, 6
47 ; CHECK-NO-ISEL-LABEL: foo2:
48 ; CHECK-NO-ISEL: # %bb.0: # %entry
49 ; CHECK-NO-ISEL-NEXT: slw 4, 3, 4
50 ; CHECK-NO-ISEL-NEXT: li 6, 0
51 ; CHECK-NO-ISEL-NEXT: li 3, 1
52 ; CHECK-NO-ISEL-NEXT: cmpwi 4, 0
53 ; CHECK-NO-ISEL-NEXT: stw 4, 0(5)
54 ; CHECK-NO-ISEL-NEXT: bclr 12, 1, 0
55 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
56 ; CHECK-NO-ISEL-NEXT: ori 3, 6, 0
57 ; CHECK-NO-ISEL-NEXT: blr
60 store i32 %shl, ptr %c, align 4
61 %cmp = icmp sgt i32 %shl, 0
62 %conv = zext i1 %cmp to i32
66 define i64 @fool(i64 %a, i64 %b, ptr nocapture %c) #0 {
68 ; CHECK: # %bb.0: # %entry
69 ; CHECK-NEXT: sub. 6, 3, 4
70 ; CHECK-NEXT: iselgt 3, 3, 4
71 ; CHECK-NEXT: std 6, 0(5)
74 ; CHECK-NO-ISEL-LABEL: fool:
75 ; CHECK-NO-ISEL: # %bb.0: # %entry
76 ; CHECK-NO-ISEL-NEXT: sub. 6, 3, 4
77 ; CHECK-NO-ISEL-NEXT: bc 12, 1, .LBB2_2
78 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
79 ; CHECK-NO-ISEL-NEXT: ori 3, 4, 0
80 ; CHECK-NO-ISEL-NEXT: b .LBB2_2
81 ; CHECK-NO-ISEL-NEXT: .LBB2_2: # %entry
82 ; CHECK-NO-ISEL-NEXT: std 6, 0(5)
83 ; CHECK-NO-ISEL-NEXT: blr
85 %sub = sub nsw i64 %a, %b
86 store i64 %sub, ptr %c, align 8
87 %cmp = icmp sgt i64 %a, %b
88 %cond = select i1 %cmp, i64 %a, i64 %b
92 define i64 @foolb(i64 %a, i64 %b, ptr nocapture %c) #0 {
94 ; CHECK: # %bb.0: # %entry
95 ; CHECK-NEXT: sub. 6, 3, 4
96 ; CHECK-NEXT: iselgt 3, 4, 3
97 ; CHECK-NEXT: std 6, 0(5)
100 ; CHECK-NO-ISEL-LABEL: foolb:
101 ; CHECK-NO-ISEL: # %bb.0: # %entry
102 ; CHECK-NO-ISEL-NEXT: sub. 6, 3, 4
103 ; CHECK-NO-ISEL-NEXT: bc 12, 1, .LBB3_1
104 ; CHECK-NO-ISEL-NEXT: b .LBB3_2
105 ; CHECK-NO-ISEL-NEXT: .LBB3_1: # %entry
106 ; CHECK-NO-ISEL-NEXT: addi 3, 4, 0
107 ; CHECK-NO-ISEL-NEXT: .LBB3_2: # %entry
108 ; CHECK-NO-ISEL-NEXT: std 6, 0(5)
109 ; CHECK-NO-ISEL-NEXT: blr
111 %sub = sub nsw i64 %a, %b
112 store i64 %sub, ptr %c, align 8
113 %cmp = icmp sle i64 %a, %b
114 %cond = select i1 %cmp, i64 %a, i64 %b
118 define i64 @foolc(i64 %a, i64 %b, ptr nocapture %c) #0 {
119 ; CHECK-LABEL: foolc:
120 ; CHECK: # %bb.0: # %entry
121 ; CHECK-NEXT: sub. 6, 4, 3
122 ; CHECK-NEXT: isellt 3, 3, 4
123 ; CHECK-NEXT: std 6, 0(5)
126 ; CHECK-NO-ISEL-LABEL: foolc:
127 ; CHECK-NO-ISEL: # %bb.0: # %entry
128 ; CHECK-NO-ISEL-NEXT: sub. 6, 4, 3
129 ; CHECK-NO-ISEL-NEXT: bc 12, 0, .LBB4_2
130 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
131 ; CHECK-NO-ISEL-NEXT: ori 3, 4, 0
132 ; CHECK-NO-ISEL-NEXT: b .LBB4_2
133 ; CHECK-NO-ISEL-NEXT: .LBB4_2: # %entry
134 ; CHECK-NO-ISEL-NEXT: std 6, 0(5)
135 ; CHECK-NO-ISEL-NEXT: blr
137 %sub = sub nsw i64 %b, %a
138 store i64 %sub, ptr %c, align 8
139 %cmp = icmp sgt i64 %a, %b
140 %cond = select i1 %cmp, i64 %a, i64 %b
144 define i64 @foold(i64 %a, i64 %b, ptr nocapture %c) #0 {
145 ; CHECK-LABEL: foold:
146 ; CHECK: # %bb.0: # %entry
147 ; CHECK-NEXT: sub. 6, 4, 3
148 ; CHECK-NEXT: iselgt 3, 3, 4
149 ; CHECK-NEXT: std 6, 0(5)
152 ; CHECK-NO-ISEL-LABEL: foold:
153 ; CHECK-NO-ISEL: # %bb.0: # %entry
154 ; CHECK-NO-ISEL-NEXT: sub. 6, 4, 3
155 ; CHECK-NO-ISEL-NEXT: bc 12, 1, .LBB5_2
156 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
157 ; CHECK-NO-ISEL-NEXT: ori 3, 4, 0
158 ; CHECK-NO-ISEL-NEXT: b .LBB5_2
159 ; CHECK-NO-ISEL-NEXT: .LBB5_2: # %entry
160 ; CHECK-NO-ISEL-NEXT: std 6, 0(5)
161 ; CHECK-NO-ISEL-NEXT: blr
163 %sub = sub nsw i64 %b, %a
164 store i64 %sub, ptr %c, align 8
165 %cmp = icmp slt i64 %a, %b
166 %cond = select i1 %cmp, i64 %a, i64 %b
170 define i64 @foold2(i64 %a, i64 %b, ptr nocapture %c) #0 {
171 ; CHECK-LABEL: foold2:
172 ; CHECK: # %bb.0: # %entry
173 ; CHECK-NEXT: sub. 6, 3, 4
174 ; CHECK-NEXT: isellt 3, 3, 4
175 ; CHECK-NEXT: std 6, 0(5)
178 ; CHECK-NO-ISEL-LABEL: foold2:
179 ; CHECK-NO-ISEL: # %bb.0: # %entry
180 ; CHECK-NO-ISEL-NEXT: sub. 6, 3, 4
181 ; CHECK-NO-ISEL-NEXT: bc 12, 0, .LBB6_2
182 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
183 ; CHECK-NO-ISEL-NEXT: ori 3, 4, 0
184 ; CHECK-NO-ISEL-NEXT: b .LBB6_2
185 ; CHECK-NO-ISEL-NEXT: .LBB6_2: # %entry
186 ; CHECK-NO-ISEL-NEXT: std 6, 0(5)
187 ; CHECK-NO-ISEL-NEXT: blr
189 %sub = sub nsw i64 %a, %b
190 store i64 %sub, ptr %c, align 8
191 %cmp = icmp slt i64 %a, %b
192 %cond = select i1 %cmp, i64 %a, i64 %b
196 define i64 @foo2l(i64 %a, i64 %b, ptr nocapture %c) #0 {
197 ; CHECK-LABEL: foo2l:
198 ; CHECK: # %bb.0: # %entry
199 ; CHECK-NEXT: sld 4, 3, 4
200 ; CHECK-NEXT: addi 3, 4, -1
201 ; CHECK-NEXT: std 4, 0(5)
202 ; CHECK-NEXT: nor 3, 3, 4
203 ; CHECK-NEXT: rldicl 3, 3, 1, 63
206 ; CHECK-NO-ISEL-LABEL: foo2l:
207 ; CHECK-NO-ISEL: # %bb.0: # %entry
208 ; CHECK-NO-ISEL-NEXT: sld 4, 3, 4
209 ; CHECK-NO-ISEL-NEXT: addi 3, 4, -1
210 ; CHECK-NO-ISEL-NEXT: std 4, 0(5)
211 ; CHECK-NO-ISEL-NEXT: nor 3, 3, 4
212 ; CHECK-NO-ISEL-NEXT: rldicl 3, 3, 1, 63
213 ; CHECK-NO-ISEL-NEXT: blr
215 %shl = shl i64 %a, %b
216 store i64 %shl, ptr %c, align 8
217 %cmp = icmp sgt i64 %shl, 0
218 %conv1 = zext i1 %cmp to i64
222 define double @food(double %a, double %b, ptr nocapture %c) #0 {
224 ; CHECK: # %bb.0: # %entry
225 ; CHECK-NEXT: fsub 0, 1, 2
226 ; CHECK-NEXT: fcmpu 0, 1, 2
227 ; CHECK-NEXT: stfd 0, 0(5)
228 ; CHECK-NEXT: bgtlr 0
229 ; CHECK-NEXT: # %bb.1: # %entry
230 ; CHECK-NEXT: fmr 1, 2
233 ; CHECK-NO-ISEL-LABEL: food:
234 ; CHECK-NO-ISEL: # %bb.0: # %entry
235 ; CHECK-NO-ISEL-NEXT: fsub 0, 1, 2
236 ; CHECK-NO-ISEL-NEXT: fcmpu 0, 1, 2
237 ; CHECK-NO-ISEL-NEXT: stfd 0, 0(5)
238 ; CHECK-NO-ISEL-NEXT: bgtlr 0
239 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
240 ; CHECK-NO-ISEL-NEXT: fmr 1, 2
241 ; CHECK-NO-ISEL-NEXT: blr
243 %sub = fsub double %a, %b
244 store double %sub, ptr %c, align 8
245 %cmp = fcmp ogt double %a, %b
246 %cond = select i1 %cmp, double %a, double %b
250 define float @foof(float %a, float %b, ptr nocapture %c) #0 {
252 ; CHECK: # %bb.0: # %entry
253 ; CHECK-NEXT: fsubs 0, 1, 2
254 ; CHECK-NEXT: fcmpu 0, 1, 2
255 ; CHECK-NEXT: stfs 0, 0(5)
256 ; CHECK-NEXT: bgtlr 0
257 ; CHECK-NEXT: # %bb.1: # %entry
258 ; CHECK-NEXT: fmr 1, 2
261 ; CHECK-NO-ISEL-LABEL: foof:
262 ; CHECK-NO-ISEL: # %bb.0: # %entry
263 ; CHECK-NO-ISEL-NEXT: fsubs 0, 1, 2
264 ; CHECK-NO-ISEL-NEXT: fcmpu 0, 1, 2
265 ; CHECK-NO-ISEL-NEXT: stfs 0, 0(5)
266 ; CHECK-NO-ISEL-NEXT: bgtlr 0
267 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
268 ; CHECK-NO-ISEL-NEXT: fmr 1, 2
269 ; CHECK-NO-ISEL-NEXT: blr
271 %sub = fsub float %a, %b
272 store float %sub, ptr %c, align 4
273 %cmp = fcmp ogt float %a, %b
274 %cond = select i1 %cmp, float %a, float %b
278 declare i64 @llvm.ctpop.i64(i64);
280 define signext i64 @fooct(i64 signext %a, i64 signext %b, ptr nocapture %c) #0 {
281 ; CHECK-LABEL: fooct:
282 ; CHECK: # %bb.0: # %entry
283 ; CHECK-NEXT: lis 6, 21845
284 ; CHECK-NEXT: sub 7, 3, 4
285 ; CHECK-NEXT: ori 6, 6, 21845
286 ; CHECK-NEXT: lis 9, 13107
287 ; CHECK-NEXT: rotldi 8, 7, 63
288 ; CHECK-NEXT: rldimi 6, 6, 32, 0
289 ; CHECK-NEXT: and 6, 8, 6
290 ; CHECK-NEXT: ori 8, 9, 13107
291 ; CHECK-NEXT: sub 6, 7, 6
292 ; CHECK-NEXT: rldimi 8, 8, 32, 0
293 ; CHECK-NEXT: lis 9, 257
294 ; CHECK-NEXT: rotldi 7, 6, 62
295 ; CHECK-NEXT: and 6, 6, 8
296 ; CHECK-NEXT: ori 9, 9, 257
297 ; CHECK-NEXT: and 7, 7, 8
298 ; CHECK-NEXT: lis 8, 3855
299 ; CHECK-NEXT: add 6, 6, 7
300 ; CHECK-NEXT: ori 7, 8, 3855
301 ; CHECK-NEXT: rldicl 8, 6, 60, 4
302 ; CHECK-NEXT: rldimi 7, 7, 32, 0
303 ; CHECK-NEXT: rldimi 9, 9, 32, 0
304 ; CHECK-NEXT: add 6, 6, 8
305 ; CHECK-NEXT: and 6, 6, 7
306 ; CHECK-NEXT: mulld 6, 6, 9
307 ; CHECK-NEXT: rldicl. 6, 6, 8, 56
308 ; CHECK-NEXT: iselgt 3, 3, 4
309 ; CHECK-NEXT: std 6, 0(5)
312 ; CHECK-NO-ISEL-LABEL: fooct:
313 ; CHECK-NO-ISEL: # %bb.0: # %entry
314 ; CHECK-NO-ISEL-NEXT: lis 6, 21845
315 ; CHECK-NO-ISEL-NEXT: sub 7, 3, 4
316 ; CHECK-NO-ISEL-NEXT: ori 6, 6, 21845
317 ; CHECK-NO-ISEL-NEXT: lis 9, 13107
318 ; CHECK-NO-ISEL-NEXT: rotldi 8, 7, 63
319 ; CHECK-NO-ISEL-NEXT: rldimi 6, 6, 32, 0
320 ; CHECK-NO-ISEL-NEXT: and 6, 8, 6
321 ; CHECK-NO-ISEL-NEXT: ori 8, 9, 13107
322 ; CHECK-NO-ISEL-NEXT: sub 6, 7, 6
323 ; CHECK-NO-ISEL-NEXT: rldimi 8, 8, 32, 0
324 ; CHECK-NO-ISEL-NEXT: lis 9, 257
325 ; CHECK-NO-ISEL-NEXT: rotldi 7, 6, 62
326 ; CHECK-NO-ISEL-NEXT: and 6, 6, 8
327 ; CHECK-NO-ISEL-NEXT: ori 9, 9, 257
328 ; CHECK-NO-ISEL-NEXT: and 7, 7, 8
329 ; CHECK-NO-ISEL-NEXT: lis 8, 3855
330 ; CHECK-NO-ISEL-NEXT: add 6, 6, 7
331 ; CHECK-NO-ISEL-NEXT: ori 7, 8, 3855
332 ; CHECK-NO-ISEL-NEXT: rldicl 8, 6, 60, 4
333 ; CHECK-NO-ISEL-NEXT: rldimi 7, 7, 32, 0
334 ; CHECK-NO-ISEL-NEXT: rldimi 9, 9, 32, 0
335 ; CHECK-NO-ISEL-NEXT: add 6, 6, 8
336 ; CHECK-NO-ISEL-NEXT: and 6, 6, 7
337 ; CHECK-NO-ISEL-NEXT: mulld 6, 6, 9
338 ; CHECK-NO-ISEL-NEXT: rldicl. 6, 6, 8, 56
339 ; CHECK-NO-ISEL-NEXT: bc 12, 1, .LBB10_2
340 ; CHECK-NO-ISEL-NEXT: # %bb.1: # %entry
341 ; CHECK-NO-ISEL-NEXT: ori 3, 4, 0
342 ; CHECK-NO-ISEL-NEXT: b .LBB10_2
343 ; CHECK-NO-ISEL-NEXT: .LBB10_2: # %entry
344 ; CHECK-NO-ISEL-NEXT: std 6, 0(5)
345 ; CHECK-NO-ISEL-NEXT: blr
347 %sub = sub nsw i64 %a, %b
348 %subc = call i64 @llvm.ctpop.i64(i64 %sub)
349 store i64 %subc, ptr %c, align 4
350 %cmp = icmp sgt i64 %subc, 0
351 %cond = select i1 %cmp, i64 %a, i64 %b