1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
4 define i8 @select_i8(i1 %test, i8 %a, i8 %b) {
5 ; MIPS32-LABEL: select_i8:
6 ; MIPS32: # %bb.0: # %entry
7 ; MIPS32-NEXT: move $2, $6
8 ; MIPS32-NEXT: andi $1, $4, 1
9 ; MIPS32-NEXT: movn $2, $5, $1
13 %cond = select i1 %test, i8 %a, i8 %b
17 define i16 @select_i16(i1 %test, i16 %a, i16 %b) {
18 ; MIPS32-LABEL: select_i16:
19 ; MIPS32: # %bb.0: # %entry
20 ; MIPS32-NEXT: move $2, $6
21 ; MIPS32-NEXT: andi $1, $4, 1
22 ; MIPS32-NEXT: movn $2, $5, $1
26 %cond = select i1 %test, i16 %a, i16 %b
30 define i32 @select_i32(i1 %test, i32 %a, i32 %b) {
31 ; MIPS32-LABEL: select_i32:
32 ; MIPS32: # %bb.0: # %entry
33 ; MIPS32-NEXT: move $2, $6
34 ; MIPS32-NEXT: andi $1, $4, 1
35 ; MIPS32-NEXT: movn $2, $5, $1
39 %cond = select i1 %test, i32 %a, i32 %b
43 define ptr @select_ptr(i1 %test, ptr %a, ptr %b) {
44 ; MIPS32-LABEL: select_ptr:
45 ; MIPS32: # %bb.0: # %entry
46 ; MIPS32-NEXT: move $2, $6
47 ; MIPS32-NEXT: andi $1, $4, 1
48 ; MIPS32-NEXT: movn $2, $5, $1
52 %cond = select i1 %test, ptr %a, ptr %b
56 define i32 @select_with_negation(i32 %a, i32 %b, i32 %x, i32 %y) {
57 ; MIPS32-LABEL: select_with_negation:
58 ; MIPS32: # %bb.0: # %entry
59 ; MIPS32-NEXT: move $2, $7
60 ; MIPS32-NEXT: slt $1, $4, $5
61 ; MIPS32-NEXT: xori $1, $1, 1
62 ; MIPS32-NEXT: andi $1, $1, 1
63 ; MIPS32-NEXT: movn $2, $6, $1
67 %cmp = icmp slt i32 %a, %b
68 %lneg = xor i1 %cmp, true
69 %cond = select i1 %lneg, i32 %x, i32 %y
73 define i64 @select_i64(i1 %test, i64 %a, i64 %b) {
74 ; MIPS32-LABEL: select_i64:
75 ; MIPS32: # %bb.0: # %entry
76 ; MIPS32-NEXT: addiu $1, $sp, 16
77 ; MIPS32-NEXT: lw $2, 0($1)
78 ; MIPS32-NEXT: addiu $1, $sp, 20
79 ; MIPS32-NEXT: lw $3, 0($1)
80 ; MIPS32-NEXT: andi $1, $4, 1
81 ; MIPS32-NEXT: movn $2, $6, $1
82 ; MIPS32-NEXT: movn $3, $7, $1
86 %cond = select i1 %test, i64 %a, i64 %b
90 define void @select_ambiguous_i64_in_fpr(i1 %test, ptr %i64_ptr_a, ptr %i64_ptr_b, ptr %i64_ptr_c) {
91 ; MIPS32-LABEL: select_ambiguous_i64_in_fpr:
92 ; MIPS32: # %bb.0: # %entry
93 ; MIPS32-NEXT: ldc1 $f2, 0($5)
94 ; MIPS32-NEXT: ldc1 $f0, 0($6)
95 ; MIPS32-NEXT: andi $1, $4, 1
96 ; MIPS32-NEXT: movn.d $f0, $f2, $1
97 ; MIPS32-NEXT: sdc1 $f0, 0($7)
101 %0 = load i64, ptr %i64_ptr_a, align 8
102 %1 = load i64, ptr %i64_ptr_b, align 8
103 %cond = select i1 %test, i64 %0, i64 %1
104 store i64 %cond, ptr %i64_ptr_c, align 8
108 define float @select_float(i1 %test, float %a, float %b) {
109 ; MIPS32-LABEL: select_float:
110 ; MIPS32: # %bb.0: # %entry
111 ; MIPS32-NEXT: andi $1, $4, 1
112 ; MIPS32-NEXT: mtc1 $5, $f1
113 ; MIPS32-NEXT: mtc1 $6, $f0
114 ; MIPS32-NEXT: movn.s $f0, $f1, $1
115 ; MIPS32-NEXT: jr $ra
118 %cond = select i1 %test, float %a, float %b
122 define void @select_ambiguous_float_in_gpr(i1 %test, ptr %f32_ptr_a, ptr %f32_ptr_b, ptr %f32_ptr_c) {
123 ; MIPS32-LABEL: select_ambiguous_float_in_gpr:
124 ; MIPS32: # %bb.0: # %entry
125 ; MIPS32-NEXT: lw $2, 0($5)
126 ; MIPS32-NEXT: lw $1, 0($6)
127 ; MIPS32-NEXT: andi $3, $4, 1
128 ; MIPS32-NEXT: movn $1, $2, $3
129 ; MIPS32-NEXT: sw $1, 0($7)
130 ; MIPS32-NEXT: jr $ra
133 %0 = load float, ptr %f32_ptr_a, align 4
134 %1 = load float, ptr %f32_ptr_b, align 4
135 %cond = select i1 %test, float %0, float %1
136 store float %cond, ptr %f32_ptr_c, align 4
140 define double @select_double(double %a, double %b, i1 %test) {
141 ; MIPS32-LABEL: select_double:
142 ; MIPS32: # %bb.0: # %entry
143 ; MIPS32-NEXT: mov.d $f0, $f14
144 ; MIPS32-NEXT: addiu $1, $sp, 16
145 ; MIPS32-NEXT: lw $1, 0($1)
146 ; MIPS32-NEXT: andi $1, $1, 1
147 ; MIPS32-NEXT: movn.d $f0, $f12, $1
148 ; MIPS32-NEXT: jr $ra
151 %cond = select i1 %test, double %a, double %b