• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4
5target 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"
6target triple = "powerpc64-unknown-linux-gnu"
7
8define signext i32 @foo(i32 signext %a, i32 signext %b, i32* nocapture %c) #0 {
9; CHECK-LABEL: foo:
10; CHECK:       # %bb.0: # %entry
11; CHECK-NEXT:    cmpw 3, 4
12; CHECK-NEXT:    iselgt 6, 3, 4
13; CHECK-NEXT:    sub 4, 3, 4
14; CHECK-NEXT:    extsw 3, 6
15; CHECK-NEXT:    stw 4, 0(5)
16; CHECK-NEXT:    blr
17;
18; CHECK-NO-ISEL-LABEL: foo:
19; CHECK-NO-ISEL:       # %bb.0: # %entry
20; CHECK-NO-ISEL-NEXT:    cmpw 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 6, 4, 0
24; CHECK-NO-ISEL-NEXT:    b .LBB0_3
25; CHECK-NO-ISEL-NEXT:  .LBB0_2: # %entry
26; CHECK-NO-ISEL-NEXT:    addi 6, 3, 0
27; CHECK-NO-ISEL-NEXT:  .LBB0_3: # %entry
28; CHECK-NO-ISEL-NEXT:    sub 4, 3, 4
29; CHECK-NO-ISEL-NEXT:    extsw 3, 6
30; CHECK-NO-ISEL-NEXT:    stw 4, 0(5)
31; CHECK-NO-ISEL-NEXT:    blr
32entry:
33  %sub = sub nsw i32 %a, %b
34  store i32 %sub, i32* %c, align 4
35  %cmp = icmp sgt i32 %a, %b
36  %cond = select i1 %cmp, i32 %a, i32 %b
37  ret i32 %cond
38}
39
40define signext i32 @foo2(i32 signext %a, i32 signext %b, i32* nocapture %c) #0 {
41; CHECK-LABEL: foo2:
42; CHECK:       # %bb.0: # %entry
43; CHECK-NEXT:    slw 4, 3, 4
44; CHECK-NEXT:    li 6, 0
45; CHECK-NEXT:    li 3, 1
46; CHECK-NEXT:    cmpwi 4, 0
47; CHECK-NEXT:    stw 4, 0(5)
48; CHECK-NEXT:    iselgt 3, 3, 6
49; CHECK-NEXT:    blr
50;
51; CHECK-NO-ISEL-LABEL: foo2:
52; CHECK-NO-ISEL:       # %bb.0: # %entry
53; CHECK-NO-ISEL-NEXT:    slw 4, 3, 4
54; CHECK-NO-ISEL-NEXT:    li 6, 0
55; CHECK-NO-ISEL-NEXT:    li 3, 1
56; CHECK-NO-ISEL-NEXT:    cmpwi 4, 0
57; CHECK-NO-ISEL-NEXT:    stw 4, 0(5)
58; CHECK-NO-ISEL-NEXT:    bclr 12, 1, 0
59; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
60; CHECK-NO-ISEL-NEXT:    ori 3, 6, 0
61; CHECK-NO-ISEL-NEXT:    blr
62entry:
63  %shl = shl i32 %a, %b
64  store i32 %shl, i32* %c, align 4
65  %cmp = icmp sgt i32 %shl, 0
66  %conv = zext i1 %cmp to i32
67  ret i32 %conv
68}
69
70define i64 @fool(i64 %a, i64 %b, i64* nocapture %c) #0 {
71; CHECK-LABEL: fool:
72; CHECK:       # %bb.0: # %entry
73; CHECK-NEXT:    sub. 6, 3, 4
74; CHECK-NEXT:    iselgt 3, 3, 4
75; CHECK-NEXT:    std 6, 0(5)
76; CHECK-NEXT:    blr
77;
78; CHECK-NO-ISEL-LABEL: fool:
79; CHECK-NO-ISEL:       # %bb.0: # %entry
80; CHECK-NO-ISEL-NEXT:    sub. 6, 3, 4
81; CHECK-NO-ISEL-NEXT:    bc 12, 1, .LBB2_2
82; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
83; CHECK-NO-ISEL-NEXT:    ori 3, 4, 0
84; CHECK-NO-ISEL-NEXT:    b .LBB2_2
85; CHECK-NO-ISEL-NEXT:  .LBB2_2: # %entry
86; CHECK-NO-ISEL-NEXT:    std 6, 0(5)
87; CHECK-NO-ISEL-NEXT:    blr
88entry:
89  %sub = sub nsw i64 %a, %b
90  store i64 %sub, i64* %c, align 8
91  %cmp = icmp sgt i64 %a, %b
92  %cond = select i1 %cmp, i64 %a, i64 %b
93  ret i64 %cond
94}
95
96define i64 @foolb(i64 %a, i64 %b, i64* nocapture %c) #0 {
97; CHECK-LABEL: foolb:
98; CHECK:       # %bb.0: # %entry
99; CHECK-NEXT:    sub. 6, 3, 4
100; CHECK-NEXT:    iselgt 3, 4, 3
101; CHECK-NEXT:    std 6, 0(5)
102; CHECK-NEXT:    blr
103;
104; CHECK-NO-ISEL-LABEL: foolb:
105; CHECK-NO-ISEL:       # %bb.0: # %entry
106; CHECK-NO-ISEL-NEXT:    sub. 6, 3, 4
107; CHECK-NO-ISEL-NEXT:    bc 12, 1, .LBB3_1
108; CHECK-NO-ISEL-NEXT:    b .LBB3_2
109; CHECK-NO-ISEL-NEXT:  .LBB3_1: # %entry
110; CHECK-NO-ISEL-NEXT:    addi 3, 4, 0
111; CHECK-NO-ISEL-NEXT:  .LBB3_2: # %entry
112; CHECK-NO-ISEL-NEXT:    std 6, 0(5)
113; CHECK-NO-ISEL-NEXT:    blr
114entry:
115  %sub = sub nsw i64 %a, %b
116  store i64 %sub, i64* %c, align 8
117  %cmp = icmp sle i64 %a, %b
118  %cond = select i1 %cmp, i64 %a, i64 %b
119  ret i64 %cond
120}
121
122define i64 @foolc(i64 %a, i64 %b, i64* nocapture %c) #0 {
123; CHECK-LABEL: foolc:
124; CHECK:       # %bb.0: # %entry
125; CHECK-NEXT:    sub. 6, 4, 3
126; CHECK-NEXT:    isellt 3, 3, 4
127; CHECK-NEXT:    std 6, 0(5)
128; CHECK-NEXT:    blr
129;
130; CHECK-NO-ISEL-LABEL: foolc:
131; CHECK-NO-ISEL:       # %bb.0: # %entry
132; CHECK-NO-ISEL-NEXT:    sub. 6, 4, 3
133; CHECK-NO-ISEL-NEXT:    bc 12, 0, .LBB4_2
134; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
135; CHECK-NO-ISEL-NEXT:    ori 3, 4, 0
136; CHECK-NO-ISEL-NEXT:    b .LBB4_2
137; CHECK-NO-ISEL-NEXT:  .LBB4_2: # %entry
138; CHECK-NO-ISEL-NEXT:    std 6, 0(5)
139; CHECK-NO-ISEL-NEXT:    blr
140entry:
141  %sub = sub nsw i64 %b, %a
142  store i64 %sub, i64* %c, align 8
143  %cmp = icmp sgt i64 %a, %b
144  %cond = select i1 %cmp, i64 %a, i64 %b
145  ret i64 %cond
146}
147
148define i64 @foold(i64 %a, i64 %b, i64* nocapture %c) #0 {
149; CHECK-LABEL: foold:
150; CHECK:       # %bb.0: # %entry
151; CHECK-NEXT:    sub. 6, 4, 3
152; CHECK-NEXT:    iselgt 3, 3, 4
153; CHECK-NEXT:    std 6, 0(5)
154; CHECK-NEXT:    blr
155;
156; CHECK-NO-ISEL-LABEL: foold:
157; CHECK-NO-ISEL:       # %bb.0: # %entry
158; CHECK-NO-ISEL-NEXT:    sub. 6, 4, 3
159; CHECK-NO-ISEL-NEXT:    bc 12, 1, .LBB5_2
160; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
161; CHECK-NO-ISEL-NEXT:    ori 3, 4, 0
162; CHECK-NO-ISEL-NEXT:    b .LBB5_2
163; CHECK-NO-ISEL-NEXT:  .LBB5_2: # %entry
164; CHECK-NO-ISEL-NEXT:    std 6, 0(5)
165; CHECK-NO-ISEL-NEXT:    blr
166entry:
167  %sub = sub nsw i64 %b, %a
168  store i64 %sub, i64* %c, align 8
169  %cmp = icmp slt i64 %a, %b
170  %cond = select i1 %cmp, i64 %a, i64 %b
171  ret i64 %cond
172}
173
174define i64 @foold2(i64 %a, i64 %b, i64* nocapture %c) #0 {
175; CHECK-LABEL: foold2:
176; CHECK:       # %bb.0: # %entry
177; CHECK-NEXT:    sub. 6, 3, 4
178; CHECK-NEXT:    isellt 3, 3, 4
179; CHECK-NEXT:    std 6, 0(5)
180; CHECK-NEXT:    blr
181;
182; CHECK-NO-ISEL-LABEL: foold2:
183; CHECK-NO-ISEL:       # %bb.0: # %entry
184; CHECK-NO-ISEL-NEXT:    sub. 6, 3, 4
185; CHECK-NO-ISEL-NEXT:    bc 12, 0, .LBB6_2
186; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
187; CHECK-NO-ISEL-NEXT:    ori 3, 4, 0
188; CHECK-NO-ISEL-NEXT:    b .LBB6_2
189; CHECK-NO-ISEL-NEXT:  .LBB6_2: # %entry
190; CHECK-NO-ISEL-NEXT:    std 6, 0(5)
191; CHECK-NO-ISEL-NEXT:    blr
192entry:
193  %sub = sub nsw i64 %a, %b
194  store i64 %sub, i64* %c, align 8
195  %cmp = icmp slt i64 %a, %b
196  %cond = select i1 %cmp, i64 %a, i64 %b
197  ret i64 %cond
198}
199
200define i64 @foo2l(i64 %a, i64 %b, i64* nocapture %c) #0 {
201; CHECK-LABEL: foo2l:
202; CHECK:       # %bb.0: # %entry
203; CHECK-NEXT:    sld 4, 3, 4
204; CHECK-NEXT:    addi 3, 4, -1
205; CHECK-NEXT:    std 4, 0(5)
206; CHECK-NEXT:    nor 3, 3, 4
207; CHECK-NEXT:    rldicl 3, 3, 1, 63
208; CHECK-NEXT:    blr
209;
210; CHECK-NO-ISEL-LABEL: foo2l:
211; CHECK-NO-ISEL:       # %bb.0: # %entry
212; CHECK-NO-ISEL-NEXT:    sld 4, 3, 4
213; CHECK-NO-ISEL-NEXT:    addi 3, 4, -1
214; CHECK-NO-ISEL-NEXT:    std 4, 0(5)
215; CHECK-NO-ISEL-NEXT:    nor 3, 3, 4
216; CHECK-NO-ISEL-NEXT:    rldicl 3, 3, 1, 63
217; CHECK-NO-ISEL-NEXT:    blr
218entry:
219  %shl = shl i64 %a, %b
220  store i64 %shl, i64* %c, align 8
221  %cmp = icmp sgt i64 %shl, 0
222  %conv1 = zext i1 %cmp to i64
223  ret i64 %conv1
224}
225
226define double @food(double %a, double %b, double* nocapture %c) #0 {
227; CHECK-LABEL: food:
228; CHECK:       # %bb.0: # %entry
229; CHECK-NEXT:    fsub 0, 1, 2
230; CHECK-NEXT:    fcmpu 0, 1, 2
231; CHECK-NEXT:    stfd 0, 0(5)
232; CHECK-NEXT:    bgtlr 0
233; CHECK-NEXT:  # %bb.1: # %entry
234; CHECK-NEXT:    fmr 1, 2
235; CHECK-NEXT:    blr
236;
237; CHECK-NO-ISEL-LABEL: food:
238; CHECK-NO-ISEL:       # %bb.0: # %entry
239; CHECK-NO-ISEL-NEXT:    fsub 0, 1, 2
240; CHECK-NO-ISEL-NEXT:    fcmpu 0, 1, 2
241; CHECK-NO-ISEL-NEXT:    stfd 0, 0(5)
242; CHECK-NO-ISEL-NEXT:    bgtlr 0
243; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
244; CHECK-NO-ISEL-NEXT:    fmr 1, 2
245; CHECK-NO-ISEL-NEXT:    blr
246entry:
247  %sub = fsub double %a, %b
248  store double %sub, double* %c, align 8
249  %cmp = fcmp ogt double %a, %b
250  %cond = select i1 %cmp, double %a, double %b
251  ret double %cond
252}
253
254define float @foof(float %a, float %b, float* nocapture %c) #0 {
255; CHECK-LABEL: foof:
256; CHECK:       # %bb.0: # %entry
257; CHECK-NEXT:    fsubs 0, 1, 2
258; CHECK-NEXT:    fcmpu 0, 1, 2
259; CHECK-NEXT:    stfs 0, 0(5)
260; CHECK-NEXT:    bgtlr 0
261; CHECK-NEXT:  # %bb.1: # %entry
262; CHECK-NEXT:    fmr 1, 2
263; CHECK-NEXT:    blr
264;
265; CHECK-NO-ISEL-LABEL: foof:
266; CHECK-NO-ISEL:       # %bb.0: # %entry
267; CHECK-NO-ISEL-NEXT:    fsubs 0, 1, 2
268; CHECK-NO-ISEL-NEXT:    fcmpu 0, 1, 2
269; CHECK-NO-ISEL-NEXT:    stfs 0, 0(5)
270; CHECK-NO-ISEL-NEXT:    bgtlr 0
271; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
272; CHECK-NO-ISEL-NEXT:    fmr 1, 2
273; CHECK-NO-ISEL-NEXT:    blr
274entry:
275  %sub = fsub float %a, %b
276  store float %sub, float* %c, align 4
277  %cmp = fcmp ogt float %a, %b
278  %cond = select i1 %cmp, float %a, float %b
279  ret float %cond
280}
281
282declare i64 @llvm.ctpop.i64(i64);
283
284define signext i64 @fooct(i64 signext %a, i64 signext %b, i64* nocapture %c) #0 {
285; CHECK-LABEL: fooct:
286; CHECK:       # %bb.0: # %entry
287; CHECK-NEXT:    lis 6, 21845
288; CHECK-NEXT:    sub 7, 3, 4
289; CHECK-NEXT:    ori 6, 6, 21845
290; CHECK-NEXT:    lis 9, 13107
291; CHECK-NEXT:    rotldi 8, 7, 63
292; CHECK-NEXT:    rldimi 6, 6, 32, 0
293; CHECK-NEXT:    and 6, 8, 6
294; CHECK-NEXT:    ori 8, 9, 13107
295; CHECK-NEXT:    sub 6, 7, 6
296; CHECK-NEXT:    rldimi 8, 8, 32, 0
297; CHECK-NEXT:    lis 9, 257
298; CHECK-NEXT:    rotldi 7, 6, 62
299; CHECK-NEXT:    and 6, 6, 8
300; CHECK-NEXT:    ori 9, 9, 257
301; CHECK-NEXT:    and 7, 7, 8
302; CHECK-NEXT:    lis 8, 3855
303; CHECK-NEXT:    add 6, 6, 7
304; CHECK-NEXT:    ori 7, 8, 3855
305; CHECK-NEXT:    rldicl 8, 6, 60, 4
306; CHECK-NEXT:    rldimi 7, 7, 32, 0
307; CHECK-NEXT:    rldimi 9, 9, 32, 0
308; CHECK-NEXT:    add 6, 6, 8
309; CHECK-NEXT:    and 6, 6, 7
310; CHECK-NEXT:    mulld 6, 6, 9
311; CHECK-NEXT:    rldicl. 6, 6, 8, 56
312; CHECK-NEXT:    iselgt 3, 3, 4
313; CHECK-NEXT:    std 6, 0(5)
314; CHECK-NEXT:    blr
315;
316; CHECK-NO-ISEL-LABEL: fooct:
317; CHECK-NO-ISEL:       # %bb.0: # %entry
318; CHECK-NO-ISEL-NEXT:    lis 6, 21845
319; CHECK-NO-ISEL-NEXT:    sub 7, 3, 4
320; CHECK-NO-ISEL-NEXT:    ori 6, 6, 21845
321; CHECK-NO-ISEL-NEXT:    lis 9, 13107
322; CHECK-NO-ISEL-NEXT:    rotldi 8, 7, 63
323; CHECK-NO-ISEL-NEXT:    rldimi 6, 6, 32, 0
324; CHECK-NO-ISEL-NEXT:    and 6, 8, 6
325; CHECK-NO-ISEL-NEXT:    ori 8, 9, 13107
326; CHECK-NO-ISEL-NEXT:    sub 6, 7, 6
327; CHECK-NO-ISEL-NEXT:    rldimi 8, 8, 32, 0
328; CHECK-NO-ISEL-NEXT:    lis 9, 257
329; CHECK-NO-ISEL-NEXT:    rotldi 7, 6, 62
330; CHECK-NO-ISEL-NEXT:    and 6, 6, 8
331; CHECK-NO-ISEL-NEXT:    ori 9, 9, 257
332; CHECK-NO-ISEL-NEXT:    and 7, 7, 8
333; CHECK-NO-ISEL-NEXT:    lis 8, 3855
334; CHECK-NO-ISEL-NEXT:    add 6, 6, 7
335; CHECK-NO-ISEL-NEXT:    ori 7, 8, 3855
336; CHECK-NO-ISEL-NEXT:    rldicl 8, 6, 60, 4
337; CHECK-NO-ISEL-NEXT:    rldimi 7, 7, 32, 0
338; CHECK-NO-ISEL-NEXT:    rldimi 9, 9, 32, 0
339; CHECK-NO-ISEL-NEXT:    add 6, 6, 8
340; CHECK-NO-ISEL-NEXT:    and 6, 6, 7
341; CHECK-NO-ISEL-NEXT:    mulld 6, 6, 9
342; CHECK-NO-ISEL-NEXT:    rldicl. 6, 6, 8, 56
343; CHECK-NO-ISEL-NEXT:    bc 12, 1, .LBB10_2
344; CHECK-NO-ISEL-NEXT:  # %bb.1: # %entry
345; CHECK-NO-ISEL-NEXT:    ori 3, 4, 0
346; CHECK-NO-ISEL-NEXT:    b .LBB10_2
347; CHECK-NO-ISEL-NEXT:  .LBB10_2: # %entry
348; CHECK-NO-ISEL-NEXT:    std 6, 0(5)
349; CHECK-NO-ISEL-NEXT:    blr
350entry:
351  %sub = sub nsw i64 %a, %b
352  %subc = call i64 @llvm.ctpop.i64(i64 %sub)
353  store i64 %subc, i64* %c, align 4
354  %cmp = icmp sgt i64 %subc, 0
355  %cond = select i1 %cmp, i64 %a, i64 %b
356  ret i64 %cond
357}
358