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: ori $1, $zero, 1
8 ; MIPS32-NEXT: and $1, $4, $1
9 ; MIPS32-NEXT: movn $6, $5, $1
10 ; MIPS32-NEXT: move $2, $6
14 %cond = select i1 %test, i8 %a, i8 %b
18 define i16 @select_i16(i1 %test, i16 %a, i16 %b) {
19 ; MIPS32-LABEL: select_i16:
20 ; MIPS32: # %bb.0: # %entry
21 ; MIPS32-NEXT: ori $1, $zero, 1
22 ; MIPS32-NEXT: and $1, $4, $1
23 ; MIPS32-NEXT: movn $6, $5, $1
24 ; MIPS32-NEXT: move $2, $6
28 %cond = select i1 %test, i16 %a, i16 %b
32 define i32 @select_i32(i1 %test, i32 %a, i32 %b) {
33 ; MIPS32-LABEL: select_i32:
34 ; MIPS32: # %bb.0: # %entry
35 ; MIPS32-NEXT: ori $1, $zero, 1
36 ; MIPS32-NEXT: and $1, $4, $1
37 ; MIPS32-NEXT: movn $6, $5, $1
38 ; MIPS32-NEXT: move $2, $6
42 %cond = select i1 %test, i32 %a, i32 %b
46 define i32* @select_ptr(i1 %test, i32* %a, i32* %b) {
47 ; MIPS32-LABEL: select_ptr:
48 ; MIPS32: # %bb.0: # %entry
49 ; MIPS32-NEXT: ori $1, $zero, 1
50 ; MIPS32-NEXT: and $1, $4, $1
51 ; MIPS32-NEXT: movn $6, $5, $1
52 ; MIPS32-NEXT: move $2, $6
56 %cond = select i1 %test, i32* %a, i32* %b
60 define i32 @select_with_negation(i32 %a, i32 %b, i32 %x, i32 %y) {
61 ; MIPS32-LABEL: select_with_negation:
62 ; MIPS32: # %bb.0: # %entry
63 ; MIPS32-NEXT: slt $1, $4, $5
64 ; MIPS32-NEXT: not $1, $1
65 ; MIPS32-NEXT: ori $2, $zero, 1
66 ; MIPS32-NEXT: and $1, $1, $2
67 ; MIPS32-NEXT: movn $7, $6, $1
68 ; MIPS32-NEXT: move $2, $7
72 %cmp = icmp slt i32 %a, %b
73 %lneg = xor i1 %cmp, true
74 %cond = select i1 %lneg, i32 %x, i32 %y
78 define i64 @select_i64(i1 %test, i64 %a, i64 %b) {
79 ; MIPS32-LABEL: select_i64:
80 ; MIPS32: # %bb.0: # %entry
81 ; MIPS32-NEXT: addiu $sp, $sp, -8
82 ; MIPS32-NEXT: .cfi_def_cfa_offset 8
83 ; MIPS32-NEXT: addiu $1, $sp, 24
84 ; MIPS32-NEXT: lw $1, 0($1)
85 ; MIPS32-NEXT: addiu $2, $sp, 28
86 ; MIPS32-NEXT: lw $2, 0($2)
87 ; MIPS32-NEXT: ori $3, $zero, 1
88 ; MIPS32-NEXT: and $3, $4, $3
89 ; MIPS32-NEXT: movn $1, $6, $3
90 ; MIPS32-NEXT: movn $2, $7, $3
91 ; MIPS32-NEXT: sw $2, 4($sp) # 4-byte Folded Spill
92 ; MIPS32-NEXT: move $2, $1
93 ; MIPS32-NEXT: lw $3, 4($sp) # 4-byte Folded Reload
94 ; MIPS32-NEXT: addiu $sp, $sp, 8
98 %cond = select i1 %test, i64 %a, i64 %b
102 define void @select_ambiguous_i64_in_fpr(i1 %test, i64* %i64_ptr_a, i64* %i64_ptr_b, i64* %i64_ptr_c) {
103 ; MIPS32-LABEL: select_ambiguous_i64_in_fpr:
104 ; MIPS32: # %bb.0: # %entry
105 ; MIPS32-NEXT: ldc1 $f0, 0($5)
106 ; MIPS32-NEXT: ldc1 $f2, 0($6)
107 ; MIPS32-NEXT: ori $1, $zero, 1
108 ; MIPS32-NEXT: and $1, $4, $1
109 ; MIPS32-NEXT: movn.d $f2, $f0, $1
110 ; MIPS32-NEXT: sdc1 $f2, 0($7)
111 ; MIPS32-NEXT: jr $ra
114 %0 = load i64, i64* %i64_ptr_a, align 8
115 %1 = load i64, i64* %i64_ptr_b, align 8
116 %cond = select i1 %test, i64 %0, i64 %1
117 store i64 %cond, i64* %i64_ptr_c, align 8
121 define float @select_float(i1 %test, float %a, float %b) {
122 ; MIPS32-LABEL: select_float:
123 ; MIPS32: # %bb.0: # %entry
124 ; MIPS32-NEXT: mtc1 $5, $f0
125 ; MIPS32-NEXT: mtc1 $6, $f1
126 ; MIPS32-NEXT: ori $1, $zero, 1
127 ; MIPS32-NEXT: and $1, $4, $1
128 ; MIPS32-NEXT: movn.s $f1, $f0, $1
129 ; MIPS32-NEXT: mov.s $f0, $f1
130 ; MIPS32-NEXT: jr $ra
133 %cond = select i1 %test, float %a, float %b
137 define void @select_ambiguous_float_in_gpr(i1 %test, float* %f32_ptr_a, float* %f32_ptr_b, float* %f32_ptr_c) {
138 ; MIPS32-LABEL: select_ambiguous_float_in_gpr:
139 ; MIPS32: # %bb.0: # %entry
140 ; MIPS32-NEXT: lw $1, 0($5)
141 ; MIPS32-NEXT: lw $2, 0($6)
142 ; MIPS32-NEXT: ori $3, $zero, 1
143 ; MIPS32-NEXT: and $3, $4, $3
144 ; MIPS32-NEXT: movn $2, $1, $3
145 ; MIPS32-NEXT: sw $2, 0($7)
146 ; MIPS32-NEXT: jr $ra
149 %0 = load float, float* %f32_ptr_a, align 4
150 %1 = load float, float* %f32_ptr_b, align 4
151 %cond = select i1 %test, float %0, float %1
152 store float %cond, float* %f32_ptr_c, align 4
156 define double @select_double(double %a, double %b, i1 %test) {
157 ; MIPS32-LABEL: select_double:
158 ; MIPS32: # %bb.0: # %entry
159 ; MIPS32-NEXT: addiu $1, $sp, 16
160 ; MIPS32-NEXT: lw $1, 0($1)
161 ; MIPS32-NEXT: ori $2, $zero, 1
162 ; MIPS32-NEXT: and $1, $1, $2
163 ; MIPS32-NEXT: movn.d $f14, $f12, $1
164 ; MIPS32-NEXT: mov.d $f0, $f14
165 ; MIPS32-NEXT: jr $ra
168 %cond = select i1 %test, double %a, double %b