llvm.org GIT mirror llvm / master test / CodeGen / AArch64 / swap-compare-operands.ll
master

Tree @master (Download .tar.gz)

swap-compare-operands.ll @masterraw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
; RUN: llc < %s -mtriple=arm64 | FileCheck %s

define i1 @testSwapCmpWithLSL64_1(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithLSL64_1:
; CHECK:      cmp     x1, x0, lsl #1
; CHECK-NEXT: cset    w0, gt
entry:
  %shl = shl i64 %a, 1
  %cmp = icmp slt i64 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithLSL64_63(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithLSL64_63:
; CHECK:      cmp     x1, x0, lsl #63
; CHECK-NEXT: cset    w0, gt
entry:
  %shl = shl i64 %a, 63
  %cmp = icmp slt i64 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithLSL32_1(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithLSL32_1:
; CHECK:      cmp     w1, w0, lsl #1
; CHECK-NEXT: cset    w0, gt
entry:
  %shl = shl i32 %a, 1
  %cmp = icmp slt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithLSL32_31(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithLSL32_31:
; CHECK:      cmp     w1, w0, lsl #31
; CHECK-NEXT: cset    w0, gt
entry:
  %shl = shl i32 %a, 31
  %cmp = icmp slt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithLSR64_1(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithLSR64_1:
; CHECK:      cmp     x1, x0, lsr #1
; CHECK-NEXT: cset    w0, gt
entry:
  %lshr = lshr i64 %a, 1
  %cmp = icmp slt i64 %lshr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithLSR64_63(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithLSR64_63:
; CHECK:      cmp     x1, x0, lsr #63
; CHECK-NEXT: cset    w0, gt
entry:
  %lshr = lshr i64 %a, 63
  %cmp = icmp slt i64 %lshr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithLSR32_1(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithLSR32_1:
; CHECK:      cmp     w1, w0, lsr #1
; CHECK-NEXT: cset    w0, gt
entry:
  %lshr = lshr i32 %a, 1
  %cmp = icmp slt i32 %lshr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithLSR32_31(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithLSR32_31:
; CHECK:      cmp     w1, w0, lsr #31
; CHECK-NEXT: cset    w0, gt
entry:
  %lshr = lshr i32 %a, 31
  %cmp = icmp slt i32 %lshr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithASR64_1(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithASR64_1:
; CHECK:      cmp     x1, x0, asr #1
; CHECK-NEXT: cset    w0, gt
entry:
  %ashr = ashr i64 %a, 1
  %cmp = icmp slt i64 %ashr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithASR64_63(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithASR64_63:
; CHECK:      cmp     x1, x0, asr #63
; CHECK-NEXT: cset    w0, gt
entry:
  %ashr = ashr i64 %a, 63
  %cmp = icmp slt i64 %ashr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithASR32_1(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithASR32_1:
; CHECK:      cmp     w1, w0, asr #1
; CHECK-NEXT: cset    w0, gt
entry:
  %ashr = ashr i32 %a, 1
  %cmp = icmp slt i32 %ashr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithASR32_31(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithASR32_31:
; CHECK:      cmp     w1, w0, asr #31
; CHECK-NEXT: cset    w0, gt
entry:
  %ashr = ashr i32 %a, 31
  %cmp = icmp slt i32 %ashr, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedZeroExtend32_64(i32 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithShiftedZeroExtend32_64
; CHECK:      cmp    x1, w0, uxtw #2
; CHECK-NEXT: cset   w0, lo
entry:
  %a64 = zext i32 %a to i64
  %shl.0 = shl i64 %a64, 2
  %cmp = icmp ugt i64 %shl.0, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedZeroExtend16_64(i16 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithShiftedZeroExtend16_64
; CHECK:      cmp    x1, w0, uxth #2
; CHECK-NEXT: cset   w0, lo
entry:
  %a64 = zext i16 %a to i64
  %shl.0 = shl i64 %a64, 2
  %cmp = icmp ugt i64 %shl.0, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedZeroExtend8_64(i8 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithShiftedZeroExtend8_64
; CHECK:      cmp    x1, w0, uxtb #4
; CHECK-NEXT: cset    w0, lo
entry:
  %a64 = zext i8 %a to i64
  %shl.2 = shl i64 %a64, 4
  %cmp = icmp ugt i64 %shl.2, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedZeroExtend16_32(i16 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithShiftedZeroExtend8_64
; CHECK:      cmp    w1, w0, uxth #3
; CHECK-NEXT: cset    w0, lo
entry:
  %a32 = zext i16 %a to i32
  %shl = shl i32 %a32, 3
  %cmp = icmp ugt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedZeroExtend8_32(i8 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithShiftedZeroExtend8_64
; CHECK:      cmp    w1, w0, uxtb #4
; CHECK-NEXT: cset    w0, lo
entry:
  %a32 = zext i8 %a to i32
  %shl = shl i32 %a32, 4
  %cmp = icmp ugt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithTooLargeShiftedZeroExtend8_32(i8 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithTooLargeShiftedZeroExtend8_64
; CHECK:      and    [[REG:w[0-9]+]], w0, #0xff
; CHECK:      cmp    w1, [[REG]], lsl #5
; CHECK-NEXT: cset   w0, lo
entry:
  %a32 = zext i8 %a to i32
  %shl = shl i32 %a32, 5
  %cmp = icmp ugt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithZeroExtend8_32(i8 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithZeroExtend8_64
; CHECK:      cmp    w1, w0, uxtb
; CHECK-NEXT: cset   w0, lo
entry:
  %a32 = zext i8 %a to i32
  %cmp = icmp ugt i32 %a32, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedSignExtend32_64(i32 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithShiftedZeroExtend32_64
; CHECK:      cmp    x1, w0, sxtw #2
; CHECK-NEXT: cset   w0, lo
entry:
  %a64 = sext i32 %a to i64
  %shl.0 = shl i64 %a64, 2
  %cmp = icmp ugt i64 %shl.0, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedSignExtend16_64(i16 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithShiftedZeroExtend16_64
; CHECK:      cmp    x1, w0, sxth #2
; CHECK-NEXT: cset   w0, lo
entry:
  %a64 = sext i16 %a to i64
  %shl.0 = shl i64 %a64, 2
  %cmp = icmp ugt i64 %shl.0, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedSignExtend8_64(i8 %a, i64 %b) {
; CHECK-LABEL testSwapCmpWithShiftedSignExtend8_64
; CHECK:      cmp    x1, w0, sxtb #4
; CHECK-NEXT: cset    w0, lo
entry:
  %a64 = sext i8 %a to i64
  %shl.2 = shl i64 %a64, 4
  %cmp = icmp ugt i64 %shl.2, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedSignExtend16_32(i16 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithShiftedSignExtend8_64
; CHECK:      cmp    w1, w0, sxth #3
; CHECK-NEXT: cset    w0, lo
entry:
  %a32 = sext i16 %a to i32
  %shl = shl i32 %a32, 3
  %cmp = icmp ugt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithShiftedSignExtend8_32(i8 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithShiftedSignExtend8_64
; CHECK:      cmp    w1, w0, sxtb #4
; CHECK-NEXT: cset   w0, lo
entry:
  %a32 = sext i8 %a to i32
  %shl = shl i32 %a32, 4
  %cmp = icmp ugt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithTooLargeShiftedSignExtend8_32(i8 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithTooLargeShiftedSignExtend8_64
; CHECK:      sxtb   [[REG:w[0-9]+]], w0
; CHECK-NEXT: cmp    w1, [[REG]], lsl #5
; CHECK-NEXT: cset   w0, lo
entry:
  %a32 = sext i8 %a to i32
  %shl = shl i32 %a32, 5
  %cmp = icmp ugt i32 %shl, %b
  ret i1 %cmp
}

define i1 @testSwapCmpWithSignExtend8_32(i8 %a, i32 %b) {
; CHECK-LABEL testSwapCmpWithSignExtend8_64
; CHECK:      cmp    w1, w0, sxtb
; CHECK-NEXT: cset   w0, lo
entry:
  %a32 = sext i8 %a to i32
  %cmp = icmp ugt i32 %a32, %b
  ret i1 %cmp
}

define i1 @testSwapCmnWithLSL64_1(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithLSL64_1:
; CHECK:      cmn    x1, x0, lsl #1
; CHECK-NEXT: cset   w0, ne
entry:
  %shl = shl i64 %a, 1
  %na = sub i64 0, %shl
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

; Note: testing with a 62 bits shift as 63 has another optimization kicking in.
define i1 @testSwapCmnWithLSL64_62(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithLSL64_62:
; CHECK:      cmn    x1, x0, lsl #62
; CHECK-NEXT: cset   w0, ne
entry:
  %shl = shl i64 %a, 62
  %na = sub i64 0, %shl
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

; Note: the 63 bits shift triggers a different optimization path, which leads
; to a similar result in terms of performances. We try to catch here any change
; so that this test can be adapted should the optimization be done with the
; operand swap.
define i1 @testSwapCmnWithLSL64_63(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithLSL64_63:
; CHECK:      cmp    x1, x0, lsl #63
; CHECK-NEXT: cset   w0, ne
entry:
  %shl = shl i64 %a, 63
  %na = sub i64 0, %shl
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

define i1 @testSwapCmnWithLSL32_1(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithLSL32_1:
; CHECK:      cmn    w1, w0, lsl #1
; CHECK-NEXT: cset   w0, ne
entry:
  %shl = shl i32 %a, 1
  %na = sub i32 0, %shl
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

; Note: testing with a 30 bits shift as 30 has another optimization kicking in.
define i1 @testSwapCmnWithLSL32_30(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithLSL32_30:
; CHECK:      cmn    w1, w0, lsl #30
; CHECK-NEXT: cset   w0, ne
entry:
  %shl = shl i32 %a, 30
  %na = sub i32 0, %shl
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

; Note: the 31 bits shift triggers a different optimization path, which leads
; to a similar result in terms of performances. We try to catch here any change
; so that this test can be adapted should the optimization be done with the
; operand swap.
define i1 @testSwapCmnWithLSL32_31(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithLSL32_31:
; CHECK:      cmp    w1, w0, lsl #31
; CHECK-NEXT: cset   w0, ne
entry:
  %shl = shl i32 %a, 31
  %na = sub i32 0, %shl
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

define i1 @testSwapCmnWithLSR64_1(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithLSR64_1:
; CHECK:      cmn    x1, x0, lsr #1
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = lshr i64 %a, 1
  %na = sub i64 0, %lshr
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

; Note: testing with a 62 bits shift as 63 has another optimization kicking in.
define i1 @testSwapCmnWithLSR64_62(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithLSR64_62:
; CHECK:      cmn    x1, x0, lsr #62
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = lshr i64 %a, 62
  %na = sub i64 0, %lshr
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

; Note: the 63 bits shift triggers a different optimization path, which leads
; to a similar result in terms of performances. We try to catch here any change
; so that this test can be adapted should the optimization be done with the
; operand swap.
define i1 @testSwapCmnWithLSR64_63(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithLSR64_63:
; CHECK:      cmp    x1, x0, asr #63
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = lshr i64 %a, 63
  %na = sub i64 0, %lshr
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

define i1 @testSwapCmnWithLSR32_1(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithLSR32_1:
; CHECK:      cmn    w1, w0, lsr #1
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = lshr i32 %a, 1
  %na = sub i32 0, %lshr
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

; Note: testing with a 30 bits shift as 31 has another optimization kicking in.
define i1 @testSwapCmnWithLSR32_30(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithLSR32_30:
; CHECK:      cmn    w1, w0, lsr #30
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = lshr i32 %a, 30
  %na = sub i32 0, %lshr
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

; Note: the 31 bits shift triggers a different optimization path, which leads
; to a similar result in terms of performances. We try to catch here any change
; so that this test can be adapted should the optimization be done with the
; operand swap.
define i1 @testSwapCmnWithLSR32_31(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithLSR32_31:
; CHECK:      cmp    w1, w0, asr #31
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = lshr i32 %a, 31
  %na = sub i32 0, %lshr
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

define i1 @testSwapCmnWithASR64_1(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithASR64_1:
; CHECK:      cmn    x1, x0, asr #3
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = ashr i64 %a, 3
  %na = sub i64 0, %lshr
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

; Note: testing with a 62 bits shift as 63 has another optimization kicking in.
define i1 @testSwapCmnWithASR64_62(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithASR64_62:
; CHECK:      cmn    x1, x0, asr #62
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = ashr i64 %a, 62
  %na = sub i64 0, %lshr
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

; Note: the 63 bits shift triggers a different optimization path, which leads
; to a similar result in terms of performances. We try to catch here any change
; so that this test can be adapted should the optimization be done with the
; operand swap.
define i1 @testSwapCmnWithASR64_63(i64 %a, i64 %b) {
; CHECK-LABEL testSwapCmnWithASR64_63:
; CHECK:      cmp    x1, x0, lsr #63
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = ashr i64 %a, 63
  %na = sub i64 0, %lshr
  %cmp = icmp ne i64 %na, %b
  ret i1 %cmp
}

define i1 @testSwapCmnWithASR32_1(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithASR32_1:
; CHECK:      cmn    w1, w0, asr #1
; CHECK-NEXT: cset   w0, eq
entry:
  %lshr = ashr i32 %a, 1
  %na = sub i32 0, %lshr
  %cmp = icmp eq i32 %na, %b
  ret i1 %cmp
}

; Note: testing with a 30 bits shift as 31 has another optimization kicking in.
define i1 @testSwapCmnWithASR32_30(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithASR32_30:
; CHECK:      cmn    w1, w0, asr #30
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = ashr i32 %a, 30
  %na = sub i32 0, %lshr
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

; Note: the 31 bits shift triggers a different optimization path, which leads
; to a similar result in terms of performances. We try to catch here any change
; so that this test can be adapted should the optimization be done with the
; operand swap.
define i1 @testSwapCmnWithASR32_31(i32 %a, i32 %b) {
; CHECK-LABEL testSwapCmnWithASR32_31:
; CHECK:      cmp    w1, w0, lsr #31
; CHECK-NEXT: cset   w0, ne
entry:
  %lshr = ashr i32 %a, 31
  %na = sub i32 0, %lshr
  %cmp = icmp ne i32 %na, %b
  ret i1 %cmp
}

define i64 @testSwapCmpToCmnWithZeroExtend(i32 %a32, i16 %a16, i8 %a8, i64 %b64, i32 %b32) {
; CHECK-LABEL testSwapCmpToCmnWithZeroExtend:
t0:
  %conv0 = zext i32 %a32 to i64
  %shl0 = shl i64 %conv0, 1
  %na0 = sub i64 0, %shl0
  %cmp0 = icmp ne i64 %na0, %b64
; CHECK: cmn    x3, w0, uxtw #1
  br i1 %cmp0, label %t1, label %end

t1:
  %conv1 = zext i16 %a16 to i64
  %shl1 = shl i64 %conv1, 4
  %na1 = sub i64 0, %shl1
  %cmp1 = icmp ne i64 %na1, %b64
; CHECK: cmn    x3, w1, uxth #4
  br i1 %cmp1, label %t2, label %end

t2:
  %conv2 = zext i8 %a8 to i64
  %shl2 = shl i64 %conv2, 3
  %na2 = sub i64 0, %shl2
  %cmp2 = icmp ne i64 %na2, %b64
; CHECK: cmn    x3, w2, uxtb #3
  br i1 %cmp2, label %t3, label %end

t3:
  %conv3 = zext i16 %a16 to i32
  %shl3 = shl i32 %conv3, 2
  %na3 = sub i32 0, %shl3
  %cmp3 = icmp ne i32 %na3, %b32
; CHECK: cmn    w4, w1, uxth #2
  br i1 %cmp3, label %t4, label %end

t4:
  %conv4 = zext i8 %a8 to i32
  %shl4 = shl i32 %conv4, 1
  %na4 = sub i32 0, %shl4
  %cmp4 = icmp ne i32 %na4, %b32
; CHECK: cmn    w4, w2, uxtb #1
  br i1 %cmp4, label %t5, label %end

t5:
  %conv5 = zext i8 %a8 to i32
  %shl5 = shl i32 %conv5, 5
  %na5 = sub i32 0, %shl5
  %cmp5 = icmp ne i32 %na5, %b32
; CHECK: and    [[REG:w[0-9]+]], w2, #0xff
; CHECK: cmn    w4, [[REG]], lsl #5
  br i1 %cmp5, label %t6, label %end

t6:
  %conv6 = zext i8 %a8 to i32
  %na6 = sub i32 0, %conv6
  %cmp6 = icmp ne i32 %na6, %b32
; CHECK: cmn    w4, w2, uxtb
  br i1 %cmp6, label %t7, label %end

t7:
  ret i64 0

end:
  ret i64 1
}
define i64 @testSwapCmpToCmnWithSignExtend(i32 %a32, i16 %a16, i8 %a8, i64 %b64, i32 %b32) {
; CHECK-LABEL testSwapCmpToCmnWithSignExtend:
t0:
  %conv0 = sext i32 %a32 to i64
  %shl0 = shl i64 %conv0, 1
  %na0 = sub i64 0, %shl0
  %cmp0 = icmp ne i64 %na0, %b64
; CHECK: cmn     x3, w0, sxtw #1
  br i1 %cmp0, label %t1, label %end

t1:
  %conv1 = sext i16 %a16 to i64
  %shl1 = shl i64 %conv1, 4
  %na1 = sub i64 0, %shl1
  %cmp1 = icmp ne i64 %na1, %b64
; CHECK: cmn     x3, w1, sxth #4
  br i1 %cmp1, label %t2, label %end

t2:
  %conv2 = sext i8 %a8 to i64
  %shl2 = shl i64 %conv2, 3
  %na2 = sub i64 0, %shl2
  %cmp2 = icmp ne i64 %na2, %b64
; CHECK: cmn     x3, w2, sxtb #3
  br i1 %cmp2, label %t3, label %end

t3:
  %conv3 = sext i16 %a16 to i32
  %shl3 = shl i32 %conv3, 2
  %na3 = sub i32 0, %shl3
  %cmp3 = icmp ne i32 %na3, %b32
; CHECK: cmn     w4, w1, sxth #2
  br i1 %cmp3, label %t4, label %end

t4:
  %conv4 = sext i8 %a8 to i32
  %shl4 = shl i32 %conv4, 1
  %na4 = sub i32 0, %shl4
  %cmp4 = icmp ne i32 %na4, %b32
; CHECK: cmn     w4, w2, sxtb #1
  br i1 %cmp4, label %t5, label %end

t5:
  %conv5 = sext i8 %a8 to i32
  %shl5 = shl i32 %conv5, 5
  %na5 = sub i32 0, %shl5
  %cmp5 = icmp ne i32 %na5, %b32
; CHECK: sxtb    [[REG:w[0-9]+]], w2
; CHECK: cmn     w4, [[REG]], lsl #5
  br i1 %cmp5, label %t6, label %end

t6:
  %conv6 = sext i8 %a8 to i32
  %na6 = sub i32 0, %conv6
  %cmp6 = icmp ne i32 %na6, %b32
; CHECK: cmn     w4, w2, sxtb
  br i1 %cmp6, label %t7, label %end

t7:
  ret i64 0

end:
  ret i64 1
}