llvm.org GIT mirror llvm / 6c00f26 test / CodeGen / Mips / cmov.ll
6c00f26

Tree @6c00f26 (Download .tar.gz)

cmov.ll @6c00f26raw · 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
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
; RUN: llc -march=mips     -mcpu=mips32                 < %s | FileCheck %s -check-prefix=ALL -check-prefix=32-CMOV
; RUN: llc -march=mips     -mcpu=mips32 -regalloc=basic < %s | FileCheck %s -check-prefix=ALL -check-prefix=32-CMOV
; RUN: llc -march=mips     -mcpu=mips32r2               < %s | FileCheck %s -check-prefix=ALL -check-prefix=32-CMOV
; RUN: llc -march=mips     -mcpu=mips32r6               < %s | FileCheck %s -check-prefix=ALL -check-prefix=32-CMP
; RUN: llc -march=mips64el -mcpu=mips4                  < %s | FileCheck %s -check-prefix=ALL -check-prefix=64-CMOV
; RUN: llc -march=mips64el -mcpu=mips64                 < %s | FileCheck %s -check-prefix=ALL -check-prefix=64-CMOV
; RUN: llc -march=mips64el -mcpu=mips64r6               < %s | FileCheck %s -check-prefix=ALL -check-prefix=64-CMP

@i1 = global [3 x i32] [i32 1, i32 2, i32 3], align 4
@i3 = common global i32* null, align 4

; ALL-LABEL: cmov1:

; 32-CMOV-DAG:  lw $[[R0:[0-9]+]], %got(i3)
; 32-CMOV-DAG:  addiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got(i1)
; 32-CMOV-DAG:  movn $[[R0]], $[[R1]], $4
; 32-CMOV-DAG:  lw $2, 0($[[R0]])

; 32-CMP-DAG:   lw $[[R0:[0-9]+]], %got(i3)
; 32-CMP-DAG:   addiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got(i1)
; 32-CMP-DAG:   selnez $[[T0:[0-9]+]], $[[R1]], $4
; 32-CMP-DAG:   seleqz $[[T1:[0-9]+]], $[[R0]], $4
; 32-CMP-DAG:   or $[[T2:[0-9]+]], $[[T0]], $[[T1]]
; 32-CMP-DAG:   lw $2, 0($[[T2]])

; 64-CMOV-DAG:  ldr $[[R0:[0-9]+]]
; 64-CMOV-DAG:  ld $[[R1:[0-9]+]], %got_disp(i1)
; 64-CMOV-DAG:  movn $[[R0]], $[[R1]], $4

; 64-CMP-DAG:   ld $[[R0:[0-9]+]], %got_disp(i3)(
; 64-CMP-DAG:   daddiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got_disp(i1)
; FIXME: This sll works around an implementation detail in the code generator
;        (setcc's result is i32 so bits 32-63 are undefined). It's not really
;        needed.
; 64-CMP-DAG:   sll $[[CC:[0-9]+]], $4, 0
; 64-CMP-DAG:   selnez $[[T0:[0-9]+]], $[[R1]], $[[CC]]
; 64-CMP-DAG:   seleqz $[[T1:[0-9]+]], $[[R0]], $[[CC]]
; 64-CMP-DAG:   or $[[T2:[0-9]+]], $[[T0]], $[[T1]]
; 64-CMP-DAG:   ld $2, 0($[[T2]])

define i32* @cmov1(i32 %s) nounwind readonly {
entry:
  %tobool = icmp ne i32 %s, 0
  %tmp1 = load i32** @i3, align 4
  %cond = select i1 %tobool, i32* getelementptr inbounds ([3 x i32]* @i1, i32 0, i32 0), i32* %tmp1
  ret i32* %cond
}

@c = global i32 1, align 4
@d = global i32 0, align 4

; ALL-LABEL: cmov2:

; 32-CMOV-DAG:  addiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got(d)
; 32-CMOV-DAG:  addiu $[[R0:[0-9]+]], ${{[0-9]+}}, %got(c)
; 32-CMOV-DAG:  movn  $[[R1]], $[[R0]], $4
; 32-CMOV-DAG:  lw $2, 0($[[R0]])

; 32-CMP-DAG:   addiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got(d)
; 32-CMP-DAG:   addiu $[[R0:[0-9]+]], ${{[0-9]+}}, %got(c)
; 32-CMP-DAG:   selnez $[[T0:[0-9]+]], $[[R0]], $4
; 32-CMP-DAG:   seleqz $[[T1:[0-9]+]], $[[R1]], $4
; 32-CMP-DAG:   or $[[T2:[0-9]+]], $[[T0]], $[[T1]]
; 32-CMP-DAG:   lw $2, 0($[[T2]])

; 64-CMOV:      daddiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got_disp(d)
; 64-CMOV:      daddiu $[[R0:[0-9]+]], ${{[0-9]+}}, %got_disp(c)
; 64-CMOV:      movn  $[[R1]], $[[R0]], $4

; 64-CMP-DAG:   daddiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got_disp(d)
; 64-CMP-DAG:   daddiu $[[R0:[0-9]+]], ${{[0-9]+}}, %got_disp(c)
; FIXME: This sll works around an implementation detail in the code generator
;        (setcc's result is i32 so bits 32-63 are undefined). It's not really
;        needed.
; 64-CMP-DAG:   sll $[[CC:[0-9]+]], $4, 0
; 64-CMP-DAG:   selnez $[[T0:[0-9]+]], $[[R0]], $[[CC]]
; 64-CMP-DAG:   seleqz $[[T1:[0-9]+]], $[[R1]], $[[CC]]
; 64-CMP-DAG:   or $[[T2:[0-9]+]], $[[T0]], $[[T1]]
; 64-CMP-DAG:   lw $2, 0($[[T2]])

define i32 @cmov2(i32 %s) nounwind readonly {
entry:
  %tobool = icmp ne i32 %s, 0
  %tmp1 = load i32* @c, align 4
  %tmp2 = load i32* @d, align 4
  %cond = select i1 %tobool, i32 %tmp1, i32 %tmp2
  ret i32 %cond
}

; ALL-LABEL: cmov3:

; We won't check the result register since we can't know if the move is first
; or last. We do know it will be either one of two registers so we can at least
; check that.

; 32-CMOV:      xori $[[R0:[0-9]+]], $4, 234
; 32-CMOV:      movz ${{[26]}}, $5, $[[R0]]

; 32-CMP-DAG:   xori $[[CC:[0-9]+]], $4, 234
; 32-CMP-DAG:   seleqz $[[T0:[0-9]+]], $5, $[[CC]]
; 32-CMP-DAG:   selnez $[[T1:[0-9]+]], $6, $[[CC]]
; 32-CMP-DAG:   or $2, $[[T0]], $[[T1]]

; 64-CMOV:      xori $[[R0:[0-9]+]], $4, 234
; 64-CMOV:      movz ${{[26]}}, $5, $[[R0]]

; 64-CMP-DAG:   xori $[[CC:[0-9]+]], $4, 234
; 64-CMP-DAG:   seleqz $[[T0:[0-9]+]], $5, $[[CC]]
; 64-CMP-DAG:   selnez $[[T1:[0-9]+]], $6, $[[CC]]
; 64-CMP-DAG:   or $2, $[[T0]], $[[T1]]

define i32 @cmov3(i32 %a, i32 %b, i32 %c) nounwind readnone {
entry:
  %cmp = icmp eq i32 %a, 234
  %cond = select i1 %cmp, i32 %b, i32 %c
  ret i32 %cond
}

; ALL-LABEL: cmov3_ne:

; We won't check the result register since we can't know if the move is first
; or last. We do know it will be either one of two registers so we can at least
; check that.

; FIXME: Use xori instead of addiu+xor.
; 32-CMOV:      addiu $[[R0:[0-9]+]], $zero, 234
; 32-CMOV:      xor $[[R1:[0-9]+]], $4, $[[R0]]
; 32-CMOV:      movn ${{[26]}}, $5, $[[R1]]

; 32-CMP-DAG:   xori $[[CC:[0-9]+]], $4, 234
; 32-CMP-DAG:   selnez $[[T0:[0-9]+]], $5, $[[CC]]
; 32-CMP-DAG:   seleqz $[[T1:[0-9]+]], $6, $[[CC]]
; 32-CMP-DAG:   or $2, $[[T0]], $[[T1]]

; FIXME: Use xori instead of addiu+xor.
; 64-CMOV:      addiu $[[R0:[0-9]+]], $zero, 234
; 64-CMOV:      xor $[[R1:[0-9]+]], $4, $[[R0]]
; 64-CMOV:      movn ${{[26]}}, $5, $[[R1]]

; 64-CMP-DAG:   xori $[[CC:[0-9]+]], $4, 234
; 64-CMP-DAG:   selnez $[[T0:[0-9]+]], $5, $[[CC]]
; 64-CMP-DAG:   seleqz $[[T1:[0-9]+]], $6, $[[CC]]
; 64-CMP-DAG:   or $2, $[[T0]], $[[T1]]

define i32 @cmov3_ne(i32 %a, i32 %b, i32 %c) nounwind readnone {
entry:
  %cmp = icmp ne i32 %a, 234
  %cond = select i1 %cmp, i32 %b, i32 %c
  ret i32 %cond
}

; ALL-LABEL: cmov4:

; We won't check the result register since we can't know if the move is first
; or last. We do know it will be one of two registers so we can at least check
; that.

; 32-CMOV-DAG: xori $[[R0:[0-9]+]], $4, 234
; 32-CMOV-DAG: lw $[[R1:2]], 16($sp)
; 32-CMOV-DAG: lw $[[R2:3]], 20($sp)
; 32-CMOV-DAG: movz $[[R1]], $6, $[[R0]]
; 32-CMOV-DAG: movz $[[R2]], $7, $[[R0]]

; 32-CMP-DAG:  xori $[[R0:[0-9]+]], $4, 234
; 32-CMP-DAG:  lw $[[R1:[0-9]+]], 16($sp)
; 32-CMP-DAG:  lw $[[R2:[0-9]+]], 20($sp)
; 32-CMP-DAG:  seleqz $[[T0:[0-9]+]], $6, $[[R0]]
; 32-CMP-DAG:  seleqz $[[T1:[0-9]+]], $7, $[[R0]]
; 32-CMP-DAG:  selnez $[[T2:[0-9]+]], $[[R1]], $[[R0]]
; 32-CMP-DAG:  selnez $[[T3:[0-9]+]], $[[R2]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T2]]
; 32-CMP-DAG:  or $3, $[[T1]], $[[T3]]

; 64-CMOV: xori $[[R0:[0-9]+]], $4, 234
; 64-CMOV: movz ${{[26]}}, $5, $[[R0]]

; 64-CMP-DAG:  xori $[[R0:[0-9]+]], $4, 234
; 64-CMP-DAG:  seleqz $[[T0:[0-9]+]], $5, $[[R0]]
; 64-CMP-DAG:  selnez $[[T1:[0-9]+]], $6, $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i64 @cmov4(i32 %a, i64 %b, i64 %c) nounwind readnone {
entry:
  %cmp = icmp eq i32 %a, 234
  %cond = select i1 %cmp, i64 %b, i64 %c
  ret i64 %cond
}

; ALL-LABEL: cmov4_ne:

; We won't check the result register since we can't know if the move is first
; or last. We do know it will be one of two registers so we can at least check
; that.

; FIXME: Use xori instead of addiu+xor.
; 32-CMOV-DAG: addiu $[[R0:[0-9]+]], $zero, 234
; 32-CMOV-DAG: xor $[[R1:[0-9]+]], $4, $[[R0]]
; 32-CMOV-DAG: lw $[[R2:2]], 16($sp)
; 32-CMOV-DAG: lw $[[R3:3]], 20($sp)
; 32-CMOV-DAG: movn $[[R2]], $6, $[[R1]]
; 32-CMOV-DAG: movn $[[R3]], $7, $[[R1]]

; 32-CMP-DAG:  xori $[[R0:[0-9]+]], $4, 234
; 32-CMP-DAG:  lw $[[R1:[0-9]+]], 16($sp)
; 32-CMP-DAG:  lw $[[R2:[0-9]+]], 20($sp)
; 32-CMP-DAG:  selnez $[[T0:[0-9]+]], $6, $[[R0]]
; 32-CMP-DAG:  selnez $[[T1:[0-9]+]], $7, $[[R0]]
; 32-CMP-DAG:  seleqz $[[T2:[0-9]+]], $[[R1]], $[[R0]]
; 32-CMP-DAG:  seleqz $[[T3:[0-9]+]], $[[R2]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T2]]
; 32-CMP-DAG:  or $3, $[[T1]], $[[T3]]

; FIXME: Use xori instead of addiu+xor.
; 64-CMOV: addiu $[[R0:[0-9]+]], $zero, 234
; 64-CMOV: xor $[[R1:[0-9]+]], $4, $[[R0]]
; 64-CMOV: movn ${{[26]}}, $5, $[[R1]]

; 64-CMP-DAG:  xori $[[R0:[0-9]+]], $4, 234
; 64-CMP-DAG:  selnez $[[T0:[0-9]+]], $5, $[[R0]]
; 64-CMP-DAG:  seleqz $[[T1:[0-9]+]], $6, $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i64 @cmov4_ne(i32 %a, i64 %b, i64 %c) nounwind readnone {
entry:
  %cmp = icmp ne i32 %a, 234
  %cond = select i1 %cmp, i64 %b, i64 %c
  ret i64 %cond
}

; slti and conditional move.
;
; Check that, pattern
;  (select (setgt a, N), t, f)
; turns into
;  (movz t, (setlt a, N + 1), f)
; if N + 1 fits in 16-bit.

; ALL-LABEL: slti0:

; 32-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: slti $[[R0:[0-9]+]], $4, 32767
; 32-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  slti $[[R0:[0-9]+]], $4, 32767
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 32-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 32-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: slti $[[R0:[0-9]+]], $4, 32767
; 64-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 64-CMP-DAG:  slti $[[R0:[0-9]+]], $4, 32767
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 64-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 64-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @slti0(i32 %a) {
entry:
  %cmp = icmp sgt i32 %a, 32766
  %cond = select i1 %cmp, i32 3, i32 5
  ret i32 %cond
}

; ALL-LABEL: slti1:

; 32-CMOV-DAG: addiu $[[I7:[0-9]+]], $zero, 7
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: addiu $[[R1:[0-9]+]], $zero, 32767
; 32-CMOV-DAG: slt $[[R0:[0-9]+]], $[[R1]], $4
; 32-CMOV-DAG: movn $[[I5]], $[[I7]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I7:[0-9]+]], $zero, 7
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  addiu $[[I32767:[0-9]+]], $zero, 32767
; 32-CMP-DAG:  slt $[[R0:[0-9]+]], $[[I32767]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 32-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I7]], $[[R0]]
; 32-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I7:[0-9]+]], $zero, 7
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: addiu $[[R1:[0-9]+]], $zero, 32767
; 64-CMOV-DAG: slt $[[R0:[0-9]+]], $[[R1]], $4
; 64-CMOV-DAG: movn $[[I5]], $[[I7]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I7:[0-9]+]], $zero, 7
; 64-CMP-DAG:  addiu $[[I5:2]], $zero, 5
; 64-CMP-DAG:  addiu $[[R1:[0-9]+]], $zero, 32767
; 64-CMP-DAG:  slt $[[R0:[0-9]+]], $[[R1]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 64-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I7]], $[[R0]]
; 64-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @slti1(i32 %a) {
entry:
  %cmp = icmp sgt i32 %a, 32767
  %cond = select i1 %cmp, i32 7, i32 5
  ret i32 %cond
}

; ALL-LABEL: slti2:

; 32-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: slti $[[R0:[0-9]+]], $4, -32768
; 32-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  slti $[[R0:[0-9]+]], $4, -32768
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 32-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 32-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: slti $[[R0:[0-9]+]], $4, -32768
; 64-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 64-CMP-DAG:  slti $[[R0:[0-9]+]], $4, -32768
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 64-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 64-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @slti2(i32 %a) {
entry:
  %cmp = icmp sgt i32 %a, -32769
  %cond = select i1 %cmp, i32 3, i32 5
  ret i32 %cond
}

; ALL-LABEL: slti3:

; 32-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: lui $[[R1:[0-9]+]], 65535
; 32-CMOV-DAG: ori $[[R1]], $[[R1]], 32766
; 32-CMOV-DAG: slt $[[R0:[0-9]+]], $[[R1]], $4
; 32-CMOV-DAG: movn $[[I5]], $[[I3]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  lui $[[IMM:[0-9]+]], 65535
; 32-CMP-DAG:  ori $[[IMM]], $[[IMM]], 32766
; 32-CMP-DAG:  slt $[[R0:[0-9]+]], $[[I32767]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 32-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 32-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: lui $[[R1:[0-9]+]], 65535
; 64-CMOV-DAG: ori $[[R1]], $[[R1]], 32766
; 64-CMOV-DAG: slt $[[R0:[0-9]+]], $[[R1]], $4
; 64-CMOV-DAG: movn $[[I5]], $[[I3]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMP-DAG:  addiu $[[I5:2]], $zero, 5
; 64-CMP-DAG:  lui $[[IMM:[0-9]+]], 65535
; 64-CMP-DAG:  ori $[[IMM]], $[[IMM]], 32766
; 64-CMP-DAG:  slt $[[R0:[0-9]+]], $[[IMM]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 64-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 64-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @slti3(i32 %a) {
entry:
  %cmp = icmp sgt i32 %a, -32770
  %cond = select i1 %cmp, i32 3, i32 5
  ret i32 %cond
}

; 64-bit patterns.

; ALL-LABEL: slti64_0:

; 32-CMOV-DAG:  slt $[[CC:[0-9]+]], $zero, $4
; 32-CMOV-DAG:  addiu $[[I32766:[0-9]+]], $zero, 32766
; 32-CMOV-DAG:  sltu $[[R1:[0-9]+]], $[[I32766]], $5
; 32-CMOV-DAG:  movz $[[CC:[0-9]+]], $[[R1]], $4
; 32-CMOV-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMOV-DAG:  addiu $[[I4:3]], $zero, 4
; 32-CMOV-DAG:  movn $[[I4]], $[[I5]], $[[CC]]
; 32-CMOV-DAG:  addiu $2, $zero, 0

; 32-CMP-DAG:   slt $[[CC0:[0-9]+]], $zero, $4
; 32-CMP-DAG:   addiu $[[I32766:[0-9]+]], $zero, 32766
; 32-CMP-DAG:   sltu $[[CC1:[0-9]+]], $[[I32766]], $5
; 32-CMP-DAG:   selnez $[[CC2:[0-9]+]], $[[CC0]], $4
; 32-CMP-DAG:   seleqz $[[CC3:[0-9]+]], $[[CC1]], $4
; 32-CMP:       or $[[CC:[0-9]+]], $[[CC3]], $[[CC2]]
; 32-CMP-DAG:   addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:   addiu $[[I4:[0-9]+]], $zero, 4
; 32-CMP-DAG:   seleqz $[[T0:[0-9]+]], $[[I4]], $[[CC]]
; 32-CMP-DAG:   selnez $[[T1:[0-9]+]], $[[I5]], $[[CC]]
; 32-CMP-DAG:   or $3, $[[T1]], $[[T0]]
; 32-CMP-DAG:   addiu $2, $zero, 0

; 64-CMOV-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 64-CMOV-DAG:  addiu $[[I4:2]], $zero, 4
; 64-CMOV-DAG:  slti $[[R0:[0-9]+]], $4, 32767
; 64-CMOV-DAG:  movz $[[I4]], $[[I5]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 64-CMP-DAG:  addiu $[[I4:[0-9]+]], $zero, 4
; 64-CMP-DAG:  slti $[[R0:[0-9]+]], $4, 32767
; FIXME: We can do better than this by adding/subtracting the result of slti
;        to/from one of the constants.
; 64-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I4]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i64 @slti64_0(i64 %a) {
entry:
  %cmp = icmp sgt i64 %a, 32766
  %conv = select i1 %cmp, i64 5, i64 4
  ret i64 %conv
}

; ALL-LABEL: slti64_1:

; 32-CMOV-DAG:  slt $[[CC:[0-9]+]], $zero, $4
; 32-CMOV-DAG:  addiu $[[I32766:[0-9]+]], $zero, 32767
; 32-CMOV-DAG:  sltu $[[R1:[0-9]+]], $[[I32766]], $5
; 32-CMOV-DAG:  movz $[[CC:[0-9]+]], $[[R1]], $4
; 32-CMOV-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMOV-DAG:  addiu $[[I4:3]], $zero, 4
; 32-CMOV-DAG:  movn $[[I4]], $[[I5]], $[[CC]]
; 32-CMOV-DAG:  addiu $2, $zero, 0

; 32-CMP-DAG:   slt $[[CC0:[0-9]+]], $zero, $4
; 32-CMP-DAG:   addiu $[[I32766:[0-9]+]], $zero, 32767
; 32-CMP-DAG:   sltu $[[CC1:[0-9]+]], $[[I32766]], $5
; 32-CMP-DAG:   selnez $[[CC2:[0-9]+]], $[[CC0]], $4
; 32-CMP-DAG:   seleqz $[[CC3:[0-9]+]], $[[CC1]], $4
; 32-CMP:       or $[[CC:[0-9]+]], $[[CC3]], $[[CC2]]
; 32-CMP-DAG:   addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:   addiu $[[I4:[0-9]+]], $zero, 4
; 32-CMP-DAG:   seleqz $[[T0:[0-9]+]], $[[I4]], $[[CC]]
; 32-CMP-DAG:   selnez $[[T1:[0-9]+]], $[[I5]], $[[CC]]
; 32-CMP-DAG:   or $3, $[[T1]], $[[T0]]
; 32-CMP-DAG:   addiu $2, $zero, 0

; 64-CMOV-DAG: daddiu $[[I5:[0-9]+]], $zero, 5
; 64-CMOV-DAG: daddiu $[[I4:2]], $zero, 4
; 64-CMOV-DAG: daddiu $[[R1:[0-9]+]], $zero, 32767
; 64-CMOV-DAG: slt $[[R0:[0-9]+]], $[[R1]], $4
; 64-CMOV-DAG: movn $[[I4]], $[[I5]], $[[R0]]

; 64-CMP-DAG:  daddiu $[[I5:[0-9]+]], $zero, 5
; 64-CMP-DAG:  daddiu $[[I4:2]], $zero, 4
; 64-CMP-DAG:  daddiu $[[R1:[0-9]+]], $zero, 32767
; 64-CMP-DAG:  slt $[[R0:[0-9]+]], $[[R1]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 64-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I4]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i64 @slti64_1(i64 %a) {
entry:
  %cmp = icmp sgt i64 %a, 32767
  %conv = select i1 %cmp, i64 5, i64 4
  ret i64 %conv
}

; ALL-LABEL: slti64_2:

; FIXME: The 32-bit versions of this test are too complicated to reasonably
;        match at the moment. They do show some missing optimizations though
;        such as:
;           (movz $a, $b, (neg $c)) -> (movn $a, $b, $c)

; 64-CMOV-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMOV-DAG:  addiu $[[I4:2]], $zero, 4
; 64-CMOV-DAG:  slti $[[R0:[0-9]+]], $4, -32768
; 64-CMOV-DAG:  movz $[[I4]], $[[I3]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMP-DAG:  addiu $[[I4:[0-9]+]], $zero, 4
; 64-CMP-DAG:  slti $[[R0:[0-9]+]], $4, -32768
; FIXME: We can do better than this by adding/subtracting the result of slti
;        to/from one of the constants.
; 64-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 64-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I4]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i64 @slti64_2(i64 %a) {
entry:
  %cmp = icmp sgt i64 %a, -32769
  %conv = select i1 %cmp, i64 3, i64 4
  ret i64 %conv
}

; ALL-LABEL: slti64_3:

; FIXME: The 32-bit versions of this test are too complicated to reasonably
;        match at the moment. They do show some missing optimizations though
;        such as:
;           (movz $a, $b, (neg $c)) -> (movn $a, $b, $c)

; 64-CMOV-DAG: daddiu $[[I5:[0-9]+]], $zero, 5
; 64-CMOV-DAG: daddiu $[[I4:2]], $zero, 4
; 64-CMOV-DAG: daddiu $[[R1:[0-9]+]], ${{[0-9]+}}, 32766
; 64-CMOV-DAG: slt $[[R0:[0-9]+]], $[[R1]], $4
; 64-CMOV-DAG: movn $[[I4]], $[[I5]], $[[R0]]

; 64-CMP-DAG:  daddiu $[[I5:[0-9]+]], $zero, 5
; 64-CMP-DAG:  daddiu $[[I4:2]], $zero, 4
; 64-CMP-DAG:  daddiu $[[R1:[0-9]+]], ${{[0-9]+}}, 32766
; 64-CMP-DAG:  slt $[[R0:[0-9]+]], $[[R1]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 64-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I4]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i64 @slti64_3(i64 %a) {
entry:
  %cmp = icmp sgt i64 %a, -32770
  %conv = select i1 %cmp, i64 5, i64 4
  ret i64 %conv
}

; sltiu instructions.

; ALL-LABEL: sltiu0:

; 32-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: sltiu $[[R0:[0-9]+]], $4, 32767
; 32-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  sltiu $[[R0:[0-9]+]], $4, 32767
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 32-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 32-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: sltiu $[[R0:[0-9]+]], $4, 32767
; 64-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 64-CMP-DAG:  sltiu $[[R0:[0-9]+]], $4, 32767
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 64-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 64-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @sltiu0(i32 %a) {
entry:
  %cmp = icmp ugt i32 %a, 32766
  %cond = select i1 %cmp, i32 3, i32 5
  ret i32 %cond
}

; ALL-LABEL: sltiu1:

; 32-CMOV-DAG: addiu $[[I7:[0-9]+]], $zero, 7
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: addiu $[[R1:[0-9]+]], $zero, 32767
; 32-CMOV-DAG: sltu $[[R0:[0-9]+]], $[[R1]], $4
; 32-CMOV-DAG: movn $[[I5]], $[[I7]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I7:[0-9]+]], $zero, 7
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  addiu $[[I32767:[0-9]+]], $zero, 32767
; 32-CMP-DAG:  sltu $[[R0:[0-9]+]], $[[I32767]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 32-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I7]], $[[R0]]
; 32-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I7:[0-9]+]], $zero, 7
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: addiu $[[R1:[0-9]+]], $zero, 32767
; 64-CMOV-DAG: sltu $[[R0:[0-9]+]], $[[R1]], $4
; 64-CMOV-DAG: movn $[[I5]], $[[I7]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I7:[0-9]+]], $zero, 7
; 64-CMP-DAG:  addiu $[[I5:2]], $zero, 5
; 64-CMP-DAG:  addiu $[[R1:[0-9]+]], $zero, 32767
; 64-CMP-DAG:  sltu $[[R0:[0-9]+]], $[[R1]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 64-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I7]], $[[R0]]
; 64-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @sltiu1(i32 %a) {
entry:
  %cmp = icmp ugt i32 %a, 32767
  %cond = select i1 %cmp, i32 7, i32 5
  ret i32 %cond
}

; ALL-LABEL: sltiu2:

; 32-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: sltiu $[[R0:[0-9]+]], $4, -32768
; 32-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  sltiu $[[R0:[0-9]+]], $4, -32768
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 32-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 32-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: sltiu $[[R0:[0-9]+]], $4, -32768
; 64-CMOV-DAG: movz $[[I5]], $[[I3]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 64-CMP-DAG:  sltiu $[[R0:[0-9]+]], $4, -32768
; FIXME: We can do better than this by using selccz to choose between +0 and +2
; 64-CMP-DAG:  seleqz $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 64-CMP-DAG:  selnez $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @sltiu2(i32 %a) {
entry:
  %cmp = icmp ugt i32 %a, -32769
  %cond = select i1 %cmp, i32 3, i32 5
  ret i32 %cond
}

; ALL-LABEL: sltiu3:

; 32-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 32-CMOV-DAG: lui $[[R1:[0-9]+]], 65535
; 32-CMOV-DAG: ori $[[R1]], $[[R1]], 32766
; 32-CMOV-DAG: sltu $[[R0:[0-9]+]], $[[R1]], $4
; 32-CMOV-DAG: movn $[[I5]], $[[I3]], $[[R0]]

; 32-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 32-CMP-DAG:  addiu $[[I5:[0-9]+]], $zero, 5
; 32-CMP-DAG:  lui $[[IMM:[0-9]+]], 65535
; 32-CMP-DAG:  ori $[[IMM]], $[[IMM]], 32766
; 32-CMP-DAG:  sltu $[[R0:[0-9]+]], $[[I32767]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 32-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 32-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 32-CMP-DAG:  or $2, $[[T0]], $[[T1]]

; 64-CMOV-DAG: addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMOV-DAG: addiu $[[I5:2]], $zero, 5
; 64-CMOV-DAG: lui $[[R1:[0-9]+]], 65535
; 64-CMOV-DAG: ori $[[R1]], $[[R1]], 32766
; 64-CMOV-DAG: sltu $[[R0:[0-9]+]], $[[R1]], $4
; 64-CMOV-DAG: movn $[[I5]], $[[I3]], $[[R0]]

; 64-CMP-DAG:  addiu $[[I3:[0-9]+]], $zero, 3
; 64-CMP-DAG:  addiu $[[I5:2]], $zero, 5
; 64-CMP-DAG:  lui $[[IMM:[0-9]+]], 65535
; 64-CMP-DAG:  ori $[[IMM]], $[[IMM]], 32766
; 64-CMP-DAG:  sltu $[[R0:[0-9]+]], $[[IMM]], $4
; FIXME: We can do better than this by using selccz to choose between -0 and -2
; 64-CMP-DAG:  selnez $[[T0:[0-9]+]], $[[I3]], $[[R0]]
; 64-CMP-DAG:  seleqz $[[T1:[0-9]+]], $[[I5]], $[[R0]]
; 64-CMP-DAG:  or $2, $[[T0]], $[[T1]]

define i32 @sltiu3(i32 %a) {
entry:
  %cmp = icmp ugt i32 %a, -32770
  %cond = select i1 %cmp, i32 3, i32 5
  ret i32 %cond
}

; Check if
;  (select (setxx a, N), x, x-1) or
;  (select (setxx a, N), x-1, x)
; doesn't generate conditional moves
; for constant operands whose difference is |1|

define i32 @slti4(i32 %a) nounwind readnone {
  %1 = icmp slt i32 %a, 7
  %2 = select i1 %1, i32 4, i32 3
  ret i32 %2
}

; ALL-LABEL: slti4:

; 32-CMOV-DAG: slti [[R1:\$[0-9]+]], $4, 7
; 32-CMOV-DAG: addiu $2, [[R1]], 3
; 32-CMOV-NOT: movn

; 32-CMP-DAG:  slti [[R1:\$[0-9]+]], $4, 7
; 32-CMP-DAG:  addiu $2, [[R1]], 3
; 32-CMP-NOT:  seleqz
; 32-CMP-NOT:  selnez

; 64-CMOV-DAG: slti [[R1:\$[0-9]+]], $4, 7
; 64-CMOV-DAG: addiu $2, [[R1]], 3
; 64-CMOV-NOT: movn

; 64-CMP-DAG:  slti [[R1:\$[0-9]+]], $4, 7
; 64-CMP-DAG:  addiu $2, [[R1]], 3
; 64-CMP-NOT:  seleqz
; 64-CMP-NOT:  selnez

define i32 @slti5(i32 %a) nounwind readnone {
  %1 = icmp slt i32 %a, 7
  %2 = select i1 %1, i32 -3, i32 -4
  ret i32 %2
}

; ALL-LABEL: slti5:

; 32-CMOV-DAG: slti [[R1:\$[0-9]+]], $4, 7
; 32-CMOV-DAG: addiu [[R3:\$[0-9]+]], [[R2:\$[a-z0-9]+]], -4
; 32-CMOV-NOT: movn

; 32-CMP-DAG:  slti [[R1:\$[0-9]+]], $4, 7
; 32-CMP-DAG:  addiu [[R3:\$[0-9]+]], [[R2:\$[a-z0-9]+]], -4
; 32-CMP-NOT:  seleqz
; 32-CMP-NOT:  selnez

; 64-CMOV-DAG: slti [[R1:\$[0-9]+]], $4, 7
; 64-CMOV-DAG: addiu [[R3:\$[0-9]+]], [[R2:\$[a-z0-9]+]], -4
; 64-CMOV-NOT: movn

; 64-CMP-DAG:  slti [[R1:\$[0-9]+]], $4, 7
; 64-CMP-DAG:  addiu [[R3:\$[0-9]+]], [[R2:\$[a-z0-9]+]], -4
; 64-CMP-NOT:  seleqz
; 64-CMP-NOT:  selnez

define i32 @slti6(i32 %a) nounwind readnone {
  %1 = icmp slt i32 %a, 7
  %2 = select i1 %1, i32 3, i32 4
  ret i32 %2
}

; ALL-LABEL: slti6:

; 32-CMOV-DAG: slti [[R1:\$[0-9]+]], $4, 7
; 32-CMOV-DAG: xori [[R1]], [[R1]], 1
; 32-CMOV-DAG: addiu [[R2:\$[0-9]+]], [[R1]], 3
; 32-CMOV-NOT: movn

; 32-CMP-DAG:  slti [[R1:\$[0-9]+]], $4, 7
; 32-CMP-DAG:  xori [[R1]], [[R1]], 1
; 32-CMP-DAG:  addiu [[R2:\$[0-9]+]], [[R1]], 3
; 32-CMP-NOT:  seleqz
; 32-CMP-NOT:  selnez

; 64-CMOV-DAG: slti [[R1:\$[0-9]+]], $4, 7
; 64-CMOV-DAG: xori [[R1]], [[R1]], 1
; 64-CMOV-DAG: addiu [[R2:\$[0-9]+]], [[R1]], 3
; 64-CMOV-NOT: movn

; 64-CMP-DAG:  slti [[R1:\$[0-9]+]], $4, 7
; 64-CMP-DAG:  xori [[R1]], [[R1]], 1
; 64-CMP-DAG:  addiu [[R2:\$[0-9]+]], [[R1]], 3
; 64-CMP-NOT:  seleqz
; 64-CMP-NOT:  selnez