1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
4 define void @phi_feeding_phi_args(i8 %a, i8 %b) {
5 ; CHECK-LABEL: phi_feeding_phi_args:
6 ; CHECK: // %bb.0: // %entry
7 ; CHECK-NEXT: and w8, w0, #0xff
8 ; CHECK-NEXT: and w9, w1, #0xff
9 ; CHECK-NEXT: cmp w8, w9
10 ; CHECK-NEXT: csel w8, w8, w9, hi
11 ; CHECK-NEXT: .LBB0_1: // %loop
12 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
13 ; CHECK-NEXT: lsl w9, w8, #1
14 ; CHECK-NEXT: sub w10, w8, #2
15 ; CHECK-NEXT: cmp w8, #254
16 ; CHECK-NEXT: csel w8, w10, w9, lo
17 ; CHECK-NEXT: cmp w8, #255
18 ; CHECK-NEXT: b.ne .LBB0_1
19 ; CHECK-NEXT: // %bb.2: // %exit
22 %0 = icmp ugt i8 %a, %b
23 br i1 %0, label %preheader, label %empty
25 empty: ; preds = %entry
28 preheader: ; preds = %empty, %entry
29 %1 = phi i8 [ %a, %entry ], [ %b, %empty ]
32 loop: ; preds = %if.end, %preheader
33 %val = phi i8 [ %1, %preheader ], [ %inc2, %if.end ]
34 %cmp = icmp ult i8 %val, -2
35 br i1 %cmp, label %if.then, label %if.else
37 if.then: ; preds = %loop
38 %inc = sub nuw i8 %val, 2
41 if.else: ; preds = %loop
42 %inc1 = shl nuw i8 %val, 1
45 if.end: ; preds = %if.else, %if.then
46 %inc2 = phi i8 [ %inc, %if.then ], [ %inc1, %if.else ]
47 %cmp1 = icmp eq i8 %inc2, -1
48 br i1 %cmp1, label %exit, label %loop
50 exit: ; preds = %if.end
54 define void @phi_feeding_phi_zeroext_args(i8 zeroext %a, i8 zeroext %b) {
55 ; CHECK-LABEL: phi_feeding_phi_zeroext_args:
56 ; CHECK: // %bb.0: // %entry
57 ; CHECK-NEXT: cmp w0, w1
58 ; CHECK-NEXT: csel w8, w0, w1, hi
59 ; CHECK-NEXT: .LBB1_1: // %loop
60 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
61 ; CHECK-NEXT: lsl w9, w8, #1
62 ; CHECK-NEXT: sub w10, w8, #2
63 ; CHECK-NEXT: cmp w8, #254
64 ; CHECK-NEXT: csel w8, w10, w9, lo
65 ; CHECK-NEXT: cmp w8, #255
66 ; CHECK-NEXT: b.ne .LBB1_1
67 ; CHECK-NEXT: // %bb.2: // %exit
70 %0 = icmp ugt i8 %a, %b
71 br i1 %0, label %preheader, label %empty
73 empty: ; preds = %entry
76 preheader: ; preds = %empty, %entry
77 %1 = phi i8 [ %a, %entry ], [ %b, %empty ]
80 loop: ; preds = %if.end, %preheader
81 %val = phi i8 [ %1, %preheader ], [ %inc2, %if.end ]
82 %cmp = icmp ult i8 %val, -2
83 br i1 %cmp, label %if.then, label %if.else
85 if.then: ; preds = %loop
86 %inc = sub nuw i8 %val, 2
89 if.else: ; preds = %loop
90 %inc1 = shl nuw i8 %val, 1
93 if.end: ; preds = %if.else, %if.then
94 %inc2 = phi i8 [ %inc, %if.then ], [ %inc1, %if.else ]
95 %cmp1 = icmp eq i8 %inc2, -1
96 br i1 %cmp1, label %exit, label %loop
98 exit: ; preds = %if.end
102 define void @phi_i16() {
103 ; CHECK-LABEL: phi_i16:
104 ; CHECK: // %bb.0: // %entry
105 ; CHECK-NEXT: mov w8, wzr
106 ; CHECK-NEXT: mov w9, #1 // =0x1
107 ; CHECK-NEXT: .LBB2_1: // %loop
108 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
109 ; CHECK-NEXT: cmp w8, #128
110 ; CHECK-NEXT: cinc w10, w9, lo
111 ; CHECK-NEXT: add w8, w8, w10
112 ; CHECK-NEXT: cmp w8, #253
113 ; CHECK-NEXT: b.lo .LBB2_1
114 ; CHECK-NEXT: // %bb.2: // %exit
119 loop: ; preds = %if.end, %entry
120 %val = phi i16 [ 0, %entry ], [ %inc2, %if.end ]
121 %cmp = icmp ult i16 %val, 128
122 br i1 %cmp, label %if.then, label %if.else
124 if.then: ; preds = %loop
125 %inc = add nuw i16 %val, 2
128 if.else: ; preds = %loop
129 %inc1 = add nuw i16 %val, 1
132 if.end: ; preds = %if.else, %if.then
133 %inc2 = phi i16 [ %inc, %if.then ], [ %inc1, %if.else ]
134 %cmp1 = icmp ult i16 %inc2, 253
135 br i1 %cmp1, label %loop, label %exit
137 exit: ; preds = %if.end
141 define i8 @ret_i8() {
142 ; CHECK-LABEL: ret_i8:
143 ; CHECK: // %bb.0: // %entry
144 ; CHECK-NEXT: mov w0, wzr
145 ; CHECK-NEXT: mov w8, #1 // =0x1
146 ; CHECK-NEXT: .LBB3_1: // %loop
147 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
148 ; CHECK-NEXT: cmp w0, #128
149 ; CHECK-NEXT: cinc w9, w8, lo
150 ; CHECK-NEXT: add w0, w0, w9
151 ; CHECK-NEXT: cmp w0, #252
152 ; CHECK-NEXT: b.hi .LBB3_1
153 ; CHECK-NEXT: // %bb.2: // %exit
158 loop: ; preds = %if.end, %entry
159 %val = phi i8 [ 0, %entry ], [ %inc2, %if.end ]
160 %cmp = icmp ult i8 %val, -128
161 br i1 %cmp, label %if.then, label %if.else
163 if.then: ; preds = %loop
164 %inc = add nuw i8 %val, 2
167 if.else: ; preds = %loop
168 %inc1 = add nuw i8 %val, 1
171 if.end: ; preds = %if.else, %if.then
172 %inc2 = phi i8 [ %inc, %if.then ], [ %inc1, %if.else ]
173 %cmp1 = icmp ult i8 %inc2, -3
174 br i1 %cmp1, label %exit, label %loop
176 exit: ; preds = %if.end
180 define i16 @phi_multiple_undefs(i16 zeroext %arg) {
181 ; CHECK-LABEL: phi_multiple_undefs:
182 ; CHECK: // %bb.0: // %entry
183 ; CHECK-NEXT: mov w8, wzr
184 ; CHECK-NEXT: mov w9, #1 // =0x1
185 ; CHECK-NEXT: .LBB4_1: // %loop
186 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
187 ; CHECK-NEXT: cmp w8, #128
188 ; CHECK-NEXT: cinc w10, w9, lo
189 ; CHECK-NEXT: add w8, w8, w10
190 ; CHECK-NEXT: cmp w8, #253
191 ; CHECK-NEXT: b.lo .LBB4_1
192 ; CHECK-NEXT: // %bb.2: // %exit
197 loop: ; preds = %if.end, %entry
198 %val = phi i16 [ undef, %entry ], [ %inc2, %if.end ]
199 %cmp = icmp ult i16 %val, 128
200 br i1 %cmp, label %if.then, label %if.else
202 if.then: ; preds = %loop
203 %inc = add nuw i16 %val, 2
206 if.else: ; preds = %loop
207 %inc1 = add nuw i16 %val, 1
210 if.end: ; preds = %if.else, %if.then
211 %inc2 = phi i16 [ %inc, %if.then ], [ %inc1, %if.else ]
212 %unrelated = phi i16 [ undef, %if.then ], [ %arg, %if.else ]
213 %cmp1 = icmp ult i16 %inc2, 253
214 br i1 %cmp1, label %loop, label %exit
216 exit: ; preds = %if.end
220 define i16 @promote_arg_return(i16 zeroext %arg1, i16 zeroext %arg2, ptr %res) {
221 ; CHECK-LABEL: promote_arg_return:
223 ; CHECK-NEXT: add w8, w0, w0, lsl #1
224 ; CHECK-NEXT: add w8, w8, #45
225 ; CHECK-NEXT: cmp w8, w1
226 ; CHECK-NEXT: cset w8, lo
227 ; CHECK-NEXT: strb w8, [x2]
229 %add = add nuw i16 %arg1, 15
230 %mul = mul nuw nsw i16 %add, 3
231 %cmp = icmp ult i16 %mul, %arg2
232 %conv = zext i1 %cmp to i8
233 store i8 %conv, ptr %res, align 1
237 define i16 @signext_bitcast_phi_select(i16 signext %start, ptr %in) {
238 ; CHECK-LABEL: signext_bitcast_phi_select:
239 ; CHECK: // %bb.0: // %entry
240 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
241 ; CHECK-NEXT: and w9, w0, #0xffff
242 ; CHECK-NEXT: cmp w8, w9, sxth
243 ; CHECK-NEXT: b.lt .LBB6_3
244 ; CHECK-NEXT: .LBB6_1: // %if.then
245 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
246 ; CHECK-NEXT: ldrh w0, [x1, w9, sxtw #1]
247 ; CHECK-NEXT: cmp w0, w9
248 ; CHECK-NEXT: b.eq .LBB6_4
249 ; CHECK-NEXT: // %bb.2: // %if.else
250 ; CHECK-NEXT: // in Loop: Header=BB6_1 Depth=1
251 ; CHECK-NEXT: lsr w10, w9, #15
252 ; CHECK-NEXT: eor w10, w10, #0x1
253 ; CHECK-NEXT: add w9, w10, w9
254 ; CHECK-NEXT: cmp w8, w9, sxth
255 ; CHECK-NEXT: b.ge .LBB6_1
256 ; CHECK-NEXT: .LBB6_3:
257 ; CHECK-NEXT: mov w0, wzr
258 ; CHECK-NEXT: .LBB6_4: // %exit
261 %const = bitcast i16 -1 to i16
264 for.body: ; preds = %if.else, %entry
265 %idx = phi i16 [ %select, %if.else ], [ %start, %entry ]
266 %cmp.i = icmp sgt i16 %idx, %const
267 br i1 %cmp.i, label %exit, label %if.then
269 if.then: ; preds = %for.body
270 %idx.next = getelementptr i16, ptr %in, i16 %idx
271 %ld = load i16, ptr %idx.next, align 2
272 %cmp1.i = icmp eq i16 %ld, %idx
273 br i1 %cmp1.i, label %exit, label %if.else
275 if.else: ; preds = %if.then
276 %lobit = lshr i16 %idx, 15
277 %lobit.not = xor i16 %lobit, 1
278 %select = add nuw i16 %lobit.not, %idx
281 exit: ; preds = %if.then, %for.body
282 %res = phi i16 [ %ld, %if.then ], [ 0, %for.body ]