1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
4 ; These test cases are inspired by C++2a std::midpoint().
5 ; See https://bugs.llvm.org/show_bug.cgi?id=40965
7 ; ---------------------------------------------------------------------------- ;
9 ; ---------------------------------------------------------------------------- ;
11 ; Values come from regs
13 define i32 @scalar_i32_signed_reg_reg(i32 %a1, i32 %a2) nounwind {
14 ; CHECK-LABEL: scalar_i32_signed_reg_reg:
16 ; CHECK-NEXT: sub w9, w1, w0
17 ; CHECK-NEXT: subs w10, w0, w1
18 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
19 ; CHECK-NEXT: csel w9, w10, w9, gt
20 ; CHECK-NEXT: cneg w8, w8, le
21 ; CHECK-NEXT: lsr w9, w9, #1
22 ; CHECK-NEXT: madd w0, w9, w8, w0
24 %t3 = icmp sgt i32 %a1, %a2 ; signed
25 %t4 = select i1 %t3, i32 -1, i32 1
26 %t5 = select i1 %t3, i32 %a2, i32 %a1
27 %t6 = select i1 %t3, i32 %a1, i32 %a2
28 %t7 = sub i32 %t6, %t5
30 %t9 = mul nsw i32 %t8, %t4 ; signed
31 %a10 = add nsw i32 %t9, %a1 ; signed
35 define i32 @scalar_i32_unsigned_reg_reg(i32 %a1, i32 %a2) nounwind {
36 ; CHECK-LABEL: scalar_i32_unsigned_reg_reg:
38 ; CHECK-NEXT: sub w9, w1, w0
39 ; CHECK-NEXT: subs w10, w0, w1
40 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
41 ; CHECK-NEXT: csel w9, w10, w9, hi
42 ; CHECK-NEXT: cneg w8, w8, ls
43 ; CHECK-NEXT: lsr w9, w9, #1
44 ; CHECK-NEXT: madd w0, w9, w8, w0
46 %t3 = icmp ugt i32 %a1, %a2
47 %t4 = select i1 %t3, i32 -1, i32 1
48 %t5 = select i1 %t3, i32 %a2, i32 %a1
49 %t6 = select i1 %t3, i32 %a1, i32 %a2
50 %t7 = sub i32 %t6, %t5
52 %t9 = mul i32 %t8, %t4
53 %a10 = add i32 %t9, %a1
57 ; Values are loaded. Only check signed case.
59 define i32 @scalar_i32_signed_mem_reg(ptr %a1_addr, i32 %a2) nounwind {
60 ; CHECK-LABEL: scalar_i32_signed_mem_reg:
62 ; CHECK-NEXT: ldr w9, [x0]
63 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
64 ; CHECK-NEXT: cmp w9, w1
65 ; CHECK-NEXT: sub w10, w1, w9
66 ; CHECK-NEXT: cneg w8, w8, le
67 ; CHECK-NEXT: subs w11, w9, w1
68 ; CHECK-NEXT: csel w10, w11, w10, gt
69 ; CHECK-NEXT: lsr w10, w10, #1
70 ; CHECK-NEXT: madd w0, w10, w8, w9
72 %a1 = load i32, ptr %a1_addr
73 %t3 = icmp sgt i32 %a1, %a2 ; signed
74 %t4 = select i1 %t3, i32 -1, i32 1
75 %t5 = select i1 %t3, i32 %a2, i32 %a1
76 %t6 = select i1 %t3, i32 %a1, i32 %a2
77 %t7 = sub i32 %t6, %t5
79 %t9 = mul nsw i32 %t8, %t4 ; signed
80 %a10 = add nsw i32 %t9, %a1 ; signed
84 define i32 @scalar_i32_signed_reg_mem(i32 %a1, ptr %a2_addr) nounwind {
85 ; CHECK-LABEL: scalar_i32_signed_reg_mem:
87 ; CHECK-NEXT: ldr w9, [x1]
88 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
89 ; CHECK-NEXT: cmp w0, w9
90 ; CHECK-NEXT: sub w10, w9, w0
91 ; CHECK-NEXT: cneg w8, w8, le
92 ; CHECK-NEXT: subs w9, w0, w9
93 ; CHECK-NEXT: csel w9, w9, w10, gt
94 ; CHECK-NEXT: lsr w9, w9, #1
95 ; CHECK-NEXT: madd w0, w9, w8, w0
97 %a2 = load i32, ptr %a2_addr
98 %t3 = icmp sgt i32 %a1, %a2 ; signed
99 %t4 = select i1 %t3, i32 -1, i32 1
100 %t5 = select i1 %t3, i32 %a2, i32 %a1
101 %t6 = select i1 %t3, i32 %a1, i32 %a2
102 %t7 = sub i32 %t6, %t5
103 %t8 = lshr i32 %t7, 1
104 %t9 = mul nsw i32 %t8, %t4 ; signed
105 %a10 = add nsw i32 %t9, %a1 ; signed
109 define i32 @scalar_i32_signed_mem_mem(ptr %a1_addr, ptr %a2_addr) nounwind {
110 ; CHECK-LABEL: scalar_i32_signed_mem_mem:
112 ; CHECK-NEXT: ldr w9, [x0]
113 ; CHECK-NEXT: ldr w10, [x1]
114 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
115 ; CHECK-NEXT: cmp w9, w10
116 ; CHECK-NEXT: sub w11, w10, w9
117 ; CHECK-NEXT: cneg w8, w8, le
118 ; CHECK-NEXT: subs w10, w9, w10
119 ; CHECK-NEXT: csel w10, w10, w11, gt
120 ; CHECK-NEXT: lsr w10, w10, #1
121 ; CHECK-NEXT: madd w0, w10, w8, w9
123 %a1 = load i32, ptr %a1_addr
124 %a2 = load i32, ptr %a2_addr
125 %t3 = icmp sgt i32 %a1, %a2 ; signed
126 %t4 = select i1 %t3, i32 -1, i32 1
127 %t5 = select i1 %t3, i32 %a2, i32 %a1
128 %t6 = select i1 %t3, i32 %a1, i32 %a2
129 %t7 = sub i32 %t6, %t5
130 %t8 = lshr i32 %t7, 1
131 %t9 = mul nsw i32 %t8, %t4 ; signed
132 %a10 = add nsw i32 %t9, %a1 ; signed
136 ; ---------------------------------------------------------------------------- ;
138 ; ---------------------------------------------------------------------------- ;
140 ; Values come from regs
142 define i64 @scalar_i64_signed_reg_reg(i64 %a1, i64 %a2) nounwind {
143 ; CHECK-LABEL: scalar_i64_signed_reg_reg:
145 ; CHECK-NEXT: sub x9, x1, x0
146 ; CHECK-NEXT: subs x10, x0, x1
147 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
148 ; CHECK-NEXT: csel x9, x10, x9, gt
149 ; CHECK-NEXT: cneg x8, x8, le
150 ; CHECK-NEXT: lsr x9, x9, #1
151 ; CHECK-NEXT: madd x0, x9, x8, x0
153 %t3 = icmp sgt i64 %a1, %a2 ; signed
154 %t4 = select i1 %t3, i64 -1, i64 1
155 %t5 = select i1 %t3, i64 %a2, i64 %a1
156 %t6 = select i1 %t3, i64 %a1, i64 %a2
157 %t7 = sub i64 %t6, %t5
158 %t8 = lshr i64 %t7, 1
159 %t9 = mul nsw i64 %t8, %t4 ; signed
160 %a10 = add nsw i64 %t9, %a1 ; signed
164 define i64 @scalar_i64_unsigned_reg_reg(i64 %a1, i64 %a2) nounwind {
165 ; CHECK-LABEL: scalar_i64_unsigned_reg_reg:
167 ; CHECK-NEXT: sub x9, x1, x0
168 ; CHECK-NEXT: subs x10, x0, x1
169 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
170 ; CHECK-NEXT: csel x9, x10, x9, hi
171 ; CHECK-NEXT: cneg x8, x8, ls
172 ; CHECK-NEXT: lsr x9, x9, #1
173 ; CHECK-NEXT: madd x0, x9, x8, x0
175 %t3 = icmp ugt i64 %a1, %a2
176 %t4 = select i1 %t3, i64 -1, i64 1
177 %t5 = select i1 %t3, i64 %a2, i64 %a1
178 %t6 = select i1 %t3, i64 %a1, i64 %a2
179 %t7 = sub i64 %t6, %t5
180 %t8 = lshr i64 %t7, 1
181 %t9 = mul i64 %t8, %t4
182 %a10 = add i64 %t9, %a1
186 ; Values are loaded. Only check signed case.
188 define i64 @scalar_i64_signed_mem_reg(ptr %a1_addr, i64 %a2) nounwind {
189 ; CHECK-LABEL: scalar_i64_signed_mem_reg:
191 ; CHECK-NEXT: ldr x9, [x0]
192 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
193 ; CHECK-NEXT: cmp x9, x1
194 ; CHECK-NEXT: sub x10, x1, x9
195 ; CHECK-NEXT: cneg x8, x8, le
196 ; CHECK-NEXT: subs x11, x9, x1
197 ; CHECK-NEXT: csel x10, x11, x10, gt
198 ; CHECK-NEXT: lsr x10, x10, #1
199 ; CHECK-NEXT: madd x0, x10, x8, x9
201 %a1 = load i64, ptr %a1_addr
202 %t3 = icmp sgt i64 %a1, %a2 ; signed
203 %t4 = select i1 %t3, i64 -1, i64 1
204 %t5 = select i1 %t3, i64 %a2, i64 %a1
205 %t6 = select i1 %t3, i64 %a1, i64 %a2
206 %t7 = sub i64 %t6, %t5
207 %t8 = lshr i64 %t7, 1
208 %t9 = mul nsw i64 %t8, %t4 ; signed
209 %a10 = add nsw i64 %t9, %a1 ; signed
213 define i64 @scalar_i64_signed_reg_mem(i64 %a1, ptr %a2_addr) nounwind {
214 ; CHECK-LABEL: scalar_i64_signed_reg_mem:
216 ; CHECK-NEXT: ldr x9, [x1]
217 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
218 ; CHECK-NEXT: cmp x0, x9
219 ; CHECK-NEXT: sub x10, x9, x0
220 ; CHECK-NEXT: cneg x8, x8, le
221 ; CHECK-NEXT: subs x9, x0, x9
222 ; CHECK-NEXT: csel x9, x9, x10, gt
223 ; CHECK-NEXT: lsr x9, x9, #1
224 ; CHECK-NEXT: madd x0, x9, x8, x0
226 %a2 = load i64, ptr %a2_addr
227 %t3 = icmp sgt i64 %a1, %a2 ; signed
228 %t4 = select i1 %t3, i64 -1, i64 1
229 %t5 = select i1 %t3, i64 %a2, i64 %a1
230 %t6 = select i1 %t3, i64 %a1, i64 %a2
231 %t7 = sub i64 %t6, %t5
232 %t8 = lshr i64 %t7, 1
233 %t9 = mul nsw i64 %t8, %t4 ; signed
234 %a10 = add nsw i64 %t9, %a1 ; signed
238 define i64 @scalar_i64_signed_mem_mem(ptr %a1_addr, ptr %a2_addr) nounwind {
239 ; CHECK-LABEL: scalar_i64_signed_mem_mem:
241 ; CHECK-NEXT: ldr x9, [x0]
242 ; CHECK-NEXT: ldr x10, [x1]
243 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
244 ; CHECK-NEXT: cmp x9, x10
245 ; CHECK-NEXT: sub x11, x10, x9
246 ; CHECK-NEXT: cneg x8, x8, le
247 ; CHECK-NEXT: subs x10, x9, x10
248 ; CHECK-NEXT: csel x10, x10, x11, gt
249 ; CHECK-NEXT: lsr x10, x10, #1
250 ; CHECK-NEXT: madd x0, x10, x8, x9
252 %a1 = load i64, ptr %a1_addr
253 %a2 = load i64, ptr %a2_addr
254 %t3 = icmp sgt i64 %a1, %a2 ; signed
255 %t4 = select i1 %t3, i64 -1, i64 1
256 %t5 = select i1 %t3, i64 %a2, i64 %a1
257 %t6 = select i1 %t3, i64 %a1, i64 %a2
258 %t7 = sub i64 %t6, %t5
259 %t8 = lshr i64 %t7, 1
260 %t9 = mul nsw i64 %t8, %t4 ; signed
261 %a10 = add nsw i64 %t9, %a1 ; signed
265 ; ---------------------------------------------------------------------------- ;
267 ; ---------------------------------------------------------------------------- ;
269 ; Values come from regs
271 define i16 @scalar_i16_signed_reg_reg(i16 %a1, i16 %a2) nounwind {
272 ; CHECK-LABEL: scalar_i16_signed_reg_reg:
274 ; CHECK-NEXT: sxth w9, w1
275 ; CHECK-NEXT: sxth w10, w0
276 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
277 ; CHECK-NEXT: subs w9, w10, w9
278 ; CHECK-NEXT: cneg w9, w9, mi
279 ; CHECK-NEXT: cneg w8, w8, le
280 ; CHECK-NEXT: lsr w9, w9, #1
281 ; CHECK-NEXT: madd w0, w9, w8, w0
283 %t3 = icmp sgt i16 %a1, %a2 ; signed
284 %t4 = select i1 %t3, i16 -1, i16 1
285 %t5 = select i1 %t3, i16 %a2, i16 %a1
286 %t6 = select i1 %t3, i16 %a1, i16 %a2
287 %t7 = sub i16 %t6, %t5
288 %t8 = lshr i16 %t7, 1
289 %t9 = mul nsw i16 %t8, %t4 ; signed
290 %a10 = add nsw i16 %t9, %a1 ; signed
294 define i16 @scalar_i16_unsigned_reg_reg(i16 %a1, i16 %a2) nounwind {
295 ; CHECK-LABEL: scalar_i16_unsigned_reg_reg:
297 ; CHECK-NEXT: and w9, w1, #0xffff
298 ; CHECK-NEXT: and w10, w0, #0xffff
299 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
300 ; CHECK-NEXT: subs w9, w10, w9
301 ; CHECK-NEXT: cneg w9, w9, mi
302 ; CHECK-NEXT: cneg w8, w8, ls
303 ; CHECK-NEXT: lsr w9, w9, #1
304 ; CHECK-NEXT: madd w0, w9, w8, w0
306 %t3 = icmp ugt i16 %a1, %a2
307 %t4 = select i1 %t3, i16 -1, i16 1
308 %t5 = select i1 %t3, i16 %a2, i16 %a1
309 %t6 = select i1 %t3, i16 %a1, i16 %a2
310 %t7 = sub i16 %t6, %t5
311 %t8 = lshr i16 %t7, 1
312 %t9 = mul i16 %t8, %t4
313 %a10 = add i16 %t9, %a1
317 ; Values are loaded. Only check signed case.
319 define i16 @scalar_i16_signed_mem_reg(ptr %a1_addr, i16 %a2) nounwind {
320 ; CHECK-LABEL: scalar_i16_signed_mem_reg:
322 ; CHECK-NEXT: sxth w9, w1
323 ; CHECK-NEXT: ldrsh w10, [x0]
324 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
325 ; CHECK-NEXT: subs w9, w10, w9
326 ; CHECK-NEXT: cneg w9, w9, mi
327 ; CHECK-NEXT: cneg w8, w8, le
328 ; CHECK-NEXT: lsr w9, w9, #1
329 ; CHECK-NEXT: madd w0, w9, w8, w10
331 %a1 = load i16, ptr %a1_addr
332 %t3 = icmp sgt i16 %a1, %a2 ; signed
333 %t4 = select i1 %t3, i16 -1, i16 1
334 %t5 = select i1 %t3, i16 %a2, i16 %a1
335 %t6 = select i1 %t3, i16 %a1, i16 %a2
336 %t7 = sub i16 %t6, %t5
337 %t8 = lshr i16 %t7, 1
338 %t9 = mul nsw i16 %t8, %t4 ; signed
339 %a10 = add nsw i16 %t9, %a1 ; signed
343 define i16 @scalar_i16_signed_reg_mem(i16 %a1, ptr %a2_addr) nounwind {
344 ; CHECK-LABEL: scalar_i16_signed_reg_mem:
346 ; CHECK-NEXT: sxth w9, w0
347 ; CHECK-NEXT: ldrsh w10, [x1]
348 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
349 ; CHECK-NEXT: subs w9, w9, w10
350 ; CHECK-NEXT: cneg w9, w9, mi
351 ; CHECK-NEXT: cneg w8, w8, le
352 ; CHECK-NEXT: lsr w9, w9, #1
353 ; CHECK-NEXT: madd w0, w9, w8, w0
355 %a2 = load i16, ptr %a2_addr
356 %t3 = icmp sgt i16 %a1, %a2 ; signed
357 %t4 = select i1 %t3, i16 -1, i16 1
358 %t5 = select i1 %t3, i16 %a2, i16 %a1
359 %t6 = select i1 %t3, i16 %a1, i16 %a2
360 %t7 = sub i16 %t6, %t5
361 %t8 = lshr i16 %t7, 1
362 %t9 = mul nsw i16 %t8, %t4 ; signed
363 %a10 = add nsw i16 %t9, %a1 ; signed
367 define i16 @scalar_i16_signed_mem_mem(ptr %a1_addr, ptr %a2_addr) nounwind {
368 ; CHECK-LABEL: scalar_i16_signed_mem_mem:
370 ; CHECK-NEXT: ldrsh w9, [x0]
371 ; CHECK-NEXT: ldrsh w10, [x1]
372 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
373 ; CHECK-NEXT: subs w10, w9, w10
374 ; CHECK-NEXT: cneg w10, w10, mi
375 ; CHECK-NEXT: cneg w8, w8, le
376 ; CHECK-NEXT: lsr w10, w10, #1
377 ; CHECK-NEXT: madd w0, w10, w8, w9
379 %a1 = load i16, ptr %a1_addr
380 %a2 = load i16, ptr %a2_addr
381 %t3 = icmp sgt i16 %a1, %a2 ; signed
382 %t4 = select i1 %t3, i16 -1, i16 1
383 %t5 = select i1 %t3, i16 %a2, i16 %a1
384 %t6 = select i1 %t3, i16 %a1, i16 %a2
385 %t7 = sub i16 %t6, %t5
386 %t8 = lshr i16 %t7, 1
387 %t9 = mul nsw i16 %t8, %t4 ; signed
388 %a10 = add nsw i16 %t9, %a1 ; signed
392 ; ---------------------------------------------------------------------------- ;
394 ; ---------------------------------------------------------------------------- ;
396 ; Values come from regs
398 define i8 @scalar_i8_signed_reg_reg(i8 %a1, i8 %a2) nounwind {
399 ; CHECK-LABEL: scalar_i8_signed_reg_reg:
401 ; CHECK-NEXT: sxtb w9, w1
402 ; CHECK-NEXT: sxtb w10, w0
403 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
404 ; CHECK-NEXT: subs w9, w10, w9
405 ; CHECK-NEXT: cneg w9, w9, mi
406 ; CHECK-NEXT: cneg w8, w8, le
407 ; CHECK-NEXT: lsr w9, w9, #1
408 ; CHECK-NEXT: madd w0, w9, w8, w0
410 %t3 = icmp sgt i8 %a1, %a2 ; signed
411 %t4 = select i1 %t3, i8 -1, i8 1
412 %t5 = select i1 %t3, i8 %a2, i8 %a1
413 %t6 = select i1 %t3, i8 %a1, i8 %a2
414 %t7 = sub i8 %t6, %t5
416 %t9 = mul nsw i8 %t8, %t4 ; signed
417 %a10 = add nsw i8 %t9, %a1 ; signed
421 define i8 @scalar_i8_unsigned_reg_reg(i8 %a1, i8 %a2) nounwind {
422 ; CHECK-LABEL: scalar_i8_unsigned_reg_reg:
424 ; CHECK-NEXT: and w9, w1, #0xff
425 ; CHECK-NEXT: and w10, w0, #0xff
426 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
427 ; CHECK-NEXT: subs w9, w10, w9
428 ; CHECK-NEXT: cneg w9, w9, mi
429 ; CHECK-NEXT: cneg w8, w8, ls
430 ; CHECK-NEXT: lsr w9, w9, #1
431 ; CHECK-NEXT: madd w0, w9, w8, w0
433 %t3 = icmp ugt i8 %a1, %a2
434 %t4 = select i1 %t3, i8 -1, i8 1
435 %t5 = select i1 %t3, i8 %a2, i8 %a1
436 %t6 = select i1 %t3, i8 %a1, i8 %a2
437 %t7 = sub i8 %t6, %t5
439 %t9 = mul i8 %t8, %t4
440 %a10 = add i8 %t9, %a1
444 ; Values are loaded. Only check signed case.
446 define i8 @scalar_i8_signed_mem_reg(ptr %a1_addr, i8 %a2) nounwind {
447 ; CHECK-LABEL: scalar_i8_signed_mem_reg:
449 ; CHECK-NEXT: sxtb w9, w1
450 ; CHECK-NEXT: ldrsb w10, [x0]
451 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
452 ; CHECK-NEXT: subs w9, w10, w9
453 ; CHECK-NEXT: cneg w9, w9, mi
454 ; CHECK-NEXT: cneg w8, w8, le
455 ; CHECK-NEXT: lsr w9, w9, #1
456 ; CHECK-NEXT: madd w0, w9, w8, w10
458 %a1 = load i8, ptr %a1_addr
459 %t3 = icmp sgt i8 %a1, %a2 ; signed
460 %t4 = select i1 %t3, i8 -1, i8 1
461 %t5 = select i1 %t3, i8 %a2, i8 %a1
462 %t6 = select i1 %t3, i8 %a1, i8 %a2
463 %t7 = sub i8 %t6, %t5
465 %t9 = mul nsw i8 %t8, %t4 ; signed
466 %a10 = add nsw i8 %t9, %a1 ; signed
470 define i8 @scalar_i8_signed_reg_mem(i8 %a1, ptr %a2_addr) nounwind {
471 ; CHECK-LABEL: scalar_i8_signed_reg_mem:
473 ; CHECK-NEXT: sxtb w9, w0
474 ; CHECK-NEXT: ldrsb w10, [x1]
475 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
476 ; CHECK-NEXT: subs w9, w9, w10
477 ; CHECK-NEXT: cneg w9, w9, mi
478 ; CHECK-NEXT: cneg w8, w8, le
479 ; CHECK-NEXT: lsr w9, w9, #1
480 ; CHECK-NEXT: madd w0, w9, w8, w0
482 %a2 = load i8, ptr %a2_addr
483 %t3 = icmp sgt i8 %a1, %a2 ; signed
484 %t4 = select i1 %t3, i8 -1, i8 1
485 %t5 = select i1 %t3, i8 %a2, i8 %a1
486 %t6 = select i1 %t3, i8 %a1, i8 %a2
487 %t7 = sub i8 %t6, %t5
489 %t9 = mul nsw i8 %t8, %t4 ; signed
490 %a10 = add nsw i8 %t9, %a1 ; signed
494 define i8 @scalar_i8_signed_mem_mem(ptr %a1_addr, ptr %a2_addr) nounwind {
495 ; CHECK-LABEL: scalar_i8_signed_mem_mem:
497 ; CHECK-NEXT: ldrsb w9, [x0]
498 ; CHECK-NEXT: ldrsb w10, [x1]
499 ; CHECK-NEXT: mov w8, #-1 // =0xffffffff
500 ; CHECK-NEXT: subs w10, w9, w10
501 ; CHECK-NEXT: cneg w10, w10, mi
502 ; CHECK-NEXT: cneg w8, w8, le
503 ; CHECK-NEXT: lsr w10, w10, #1
504 ; CHECK-NEXT: madd w0, w10, w8, w9
506 %a1 = load i8, ptr %a1_addr
507 %a2 = load i8, ptr %a2_addr
508 %t3 = icmp sgt i8 %a1, %a2 ; signed
509 %t4 = select i1 %t3, i8 -1, i8 1
510 %t5 = select i1 %t3, i8 %a2, i8 %a1
511 %t6 = select i1 %t3, i8 %a1, i8 %a2
512 %t7 = sub i8 %t6, %t5
514 %t9 = mul nsw i8 %t8, %t4 ; signed
515 %a10 = add nsw i8 %t9, %a1 ; signed