1 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-v128:128:128-n32:64"
2 target triple = "powerpc64-unknown-linux-gnu"
3 ; RUN: llc -ppc-gpr-icmps=all -verify-machineinstrs -O2 -ppc-asm-full-reg-names -mcpu=pwr7 -ppc-gen-isel=false < %s | FileCheck %s --implicit-check-not isel
5 define signext i32 @testExpandISELToIfElse(i32 signext %i, i32 signext %j) {
7 %cmp = icmp sgt i32 %i, 0
8 %add = add nsw i32 %i, 1
9 %cond = select i1 %cmp, i32 %add, i32 %j
12 ; CHECK-LABEL: @testExpandISELToIfElse
13 ; CHECK: addi r5, r3, 1
14 ; CHECK-NEXT: cmpwi r3, 0
15 ; CHECK-NEXT: bc 12, gt, [[TRUE:.LBB[0-9]+]]
16 ; CHECK: ori r3, r4, 0
17 ; CHECK-NEXT: b [[SUCCESSOR:.LBB[0-9]+]]
18 ; CHECK-NEXT: [[TRUE]]
19 ; CHECK-NEXT: addi r3, r5, 0
20 ; CHECK-NEXT: [[SUCCESSOR]]
21 ; CHECK-NEXT: extsw r3, r3
26 define signext i32 @testExpandISELToIf(i32 signext %i, i32 signext %j) {
28 %cmp = icmp sgt i32 %i, 0
29 %cond = select i1 %cmp, i32 %j, i32 %i
32 ; CHECK-LABEL: @testExpandISELToIf
34 ; CHECK-NEXT: bc 12, gt, [[TRUE:.LBB[0-9]+]]
36 ; CHECK-NEXT: [[TRUE]]
37 ; CHECK-NEXT: addi r3, r4, 0
41 define signext i32 @testExpandISELToElse(i32 signext %i, i32 signext %j) {
43 %cmp = icmp sgt i32 %i, 0
44 %cond = select i1 %cmp, i32 %i, i32 %j
47 ; CHECK-LABEL: @testExpandISELToElse
49 ; CHECK-NEXT: bclr 12, gt, 0
50 ; CHECK: ori r3, r4, 0
55 define signext i32 @testExpandISELToNull(i32 signext %i, i32 signext %j) {
57 %cmp = icmp sgt i32 %i, 0
58 %cond = select i1 %cmp, i32 %i, i32 %i
61 ; CHECK-LABEL: @testExpandISELToNull
62 ; CHECK-NOT: b {{.LBB[0-9]+}}
67 define signext i32 @testExpandISELsTo2ORIs2ADDIs
68 (i32 signext %a, i32 signext %b, i32 signext %d,
69 i32 signext %f, i32 signext %g) {
72 %cmp = icmp sgt i32 %g, 0
73 %a.b = select i1 %cmp, i32 %g, i32 %b
74 %d.f = select i1 %cmp, i32 %d, i32 %f
75 %add = add nsw i32 %a.b, %d.f
78 ; CHECK-LABEL: @testExpandISELsTo2ORIs2ADDIs
80 ; CHECK-NEXT: bc 12, gt, [[TRUE:.LBB[0-9]+]]
81 ; CHECK: ori r3, r4, 0
82 ; CHECK-NEXT: ori r4, r6, 0
83 ; CHECK-NEXT: b [[SUCCESSOR:.LBB[0-9]+]]
84 ; CHECK-NEXT: [[TRUE]]
85 ; CHECK-NEXT: addi r3, r7, 0
86 ; CHECK-NEXT: addi r4, r5, 0
87 ; CHECK-NEXT: [[SUCCESSOR]]
88 ; CHECK-NEXT: add r3, r3, r4
89 ; CHECK-NEXT: extsw r3, r3
93 define signext i32 @testExpandISELsTo2ORIs1ADDI
94 (i32 signext %a, i32 signext %b, i32 signext %d,
95 i32 signext %f, i32 signext %g) {
97 %cmp = icmp sgt i32 %g, 0
98 %a.b = select i1 %cmp, i32 %a, i32 %b
99 %d.f = select i1 %cmp, i32 %d, i32 %f
100 %add = add nsw i32 %a.b, %d.f
103 ; CHECK-LABEL: @testExpandISELsTo2ORIs1ADDI
105 ; CHECK-NEXT: bc 12, gt, [[TRUE:.LBB[0-9]+]]
106 ; CHECK: ori r3, r4, 0
107 ; CHECK-NEXT: ori r4, r6, 0
108 ; CHECK-NEXT: b [[SUCCESSOR:.LBB[0-9]+]]
109 ; CHECK-NEXT: [[TRUE]]
110 ; CHECK-NEXT: addi r4, r5, 0
111 ; CHECK-NEXT: [[SUCCESSOR]]
112 ; CHECK-NEXT: add r3, r3, r4
113 ; CHECK-NEXT: extsw r3, r3
117 define signext i32 @testExpandISELsTo1ORI1ADDI
118 (i32 signext %a, i32 signext %b, i32 signext %d,
119 i32 signext %f, i32 signext %g) {
122 %cmp = icmp sgt i32 %g, 0
123 %a.b = select i1 %cmp, i32 %a, i32 %b
124 %d.f = select i1 %cmp, i32 %d, i32 %f
125 %add1 = add nsw i32 %a.b, %d.f
126 %add2 = add nsw i32 %a, %add1
129 ; CHECK-LABEL: @testExpandISELsTo1ORI1ADDI
131 ; CHECK-NEXT: bc 12, gt, [[TRUE:.LBB[0-9]+]]
132 ; CHECK: ori r5, r6, 0
133 ; CHECK-NEXT: b [[SUCCESSOR:.LBB[0-9]+]]
134 ; CHECK-NEXT: [[TRUE]]
135 ; CHECK-NEXT: addi r4, r3, 0
136 ; CHECK-NEXT: [[SUCCESSOR]]
137 ; CHECK-NEXT: add r4, r4, r5
138 ; CHECK-NEXT: add r3, r3, r4
139 ; CHECK-NEXT: extsw r3, r3
143 define signext i32 @testExpandISELsTo0ORI2ADDIs
144 (i32 signext %a, i32 signext %b, i32 signext %d,
145 i32 signext %f, i32 signext %g) {
148 %cmp = icmp sgt i32 %g, 0
149 %a.b = select i1 %cmp, i32 %a, i32 %b
150 %d.f = select i1 %cmp, i32 %d, i32 %f
151 %add1 = add nsw i32 %a.b, %d.f
152 %add2 = add nsw i32 %a, %add1
153 %sub1 = sub nsw i32 %add2, %d
156 ; CHECK-LABEL: @testExpandISELsTo0ORI2ADDIs
158 ; CHECK-NEXT: bc 12, gt, [[TRUE:.LBB[0-9]+]]
159 ; CHECK-NEXT: b [[SUCCESSOR:.LBB[0-9]+]]
160 ; CHECK-NEXT: [[TRUE]]
161 ; CHECK-NEXT: addi r4, r3, 0
162 ; CHECK-NEXT: addi r6, r5, 0
163 ; CHECK-NEXT: [[SUCCESSOR]]
164 ; CHECK-NEXT: add r4, r4, r6
165 ; CHECK-NEXT: add r3, r3, r4
166 ; CHECK-NEXT: sub r3, r3, r5
167 ; CHECK-NEXT: extsw r3, r3
172 @b = local_unnamed_addr global i32 0, align 4
173 @a = local_unnamed_addr global i32 0, align 4
174 ; Function Attrs: norecurse nounwind readonly
175 define signext i32 @testComplexISEL() #0 {
177 %0 = load i32, ptr @b, align 4, !tbaa !1
178 %tobool = icmp eq i32 %0, 0
179 br i1 %tobool, label %if.end, label %cleanup
182 %1 = load i32, ptr @a, align 4, !tbaa !1
183 %conv = sext i32 %1 to i64
184 %2 = inttoptr i64 %conv to ptr
185 %cmp = icmp eq ptr %2, @testComplexISEL
186 %conv3 = zext i1 %cmp to i32
190 %retval.0 = phi i32 [ %conv3, %if.end ], [ 1, %entry ]
193 ; CHECK-LABEL: @testComplexISEL
194 ; CHECK: cmplwi r3, 0
197 ; CHECK: xor [[XOR:r[0-9]+]]
198 ; CHECK: cntlzd [[CZ:r[0-9]+]], [[XOR]]
199 ; CHECK: rldicl [[SH:r[0-9]+]], [[CZ]], 58, 63
202 !1 = !{!2, !2, i64 0}
203 !2 = !{!"int", !3, i64 0}
204 !3 = !{!"omnipotent char", !4, i64 0}
205 !4 = !{!"Simple C/C++ TBAA"}