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 i32* @select_ptr(i1 %test, i32* %a, i32* %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, i32* %a, i32* %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: ori $3, $zero, 1
61 ; MIPS32-NEXT: slt $1, $4, $5
62 ; MIPS32-NEXT: xor $1, $1, $3
63 ; MIPS32-NEXT: andi $1, $1, 1
64 ; MIPS32-NEXT: movn $2, $6, $1
68 %cmp = icmp slt i32 %a, %b
69 %lneg = xor i1 %cmp, true
70 %cond = select i1 %lneg, i32 %x, i32 %y
74 define i64 @select_i64(i1 %test, i64 %a, i64 %b) {
75 ; MIPS32-LABEL: select_i64:
76 ; MIPS32: # %bb.0: # %entry
77 ; MIPS32-NEXT: addiu $1, $sp, 16
78 ; MIPS32-NEXT: lw $2, 0($1)
79 ; MIPS32-NEXT: addiu $1, $sp, 20
80 ; MIPS32-NEXT: lw $3, 0($1)
81 ; MIPS32-NEXT: andi $1, $4, 1
82 ; MIPS32-NEXT: movn $2, $6, $1
83 ; MIPS32-NEXT: movn $3, $7, $1
87 %cond = select i1 %test, i64 %a, i64 %b
91 define void @select_ambiguous_i64_in_fpr(i1 %test, i64* %i64_ptr_a, i64* %i64_ptr_b, i64* %i64_ptr_c) {
92 ; MIPS32-LABEL: select_ambiguous_i64_in_fpr:
93 ; MIPS32: # %bb.0: # %entry
94 ; MIPS32-NEXT: ldc1 $f2, 0($5)
95 ; MIPS32-NEXT: ldc1 $f0, 0($6)
96 ; MIPS32-NEXT: andi $1, $4, 1
97 ; MIPS32-NEXT: movn.d $f0, $f2, $1
98 ; MIPS32-NEXT: sdc1 $f0, 0($7)
102 %0 = load i64, i64* %i64_ptr_a, align 8
103 %1 = load i64, i64* %i64_ptr_b, align 8
104 %cond = select i1 %test, i64 %0, i64 %1
105 store i64 %cond, i64* %i64_ptr_c, align 8
109 define float @select_float(i1 %test, float %a, float %b) {
110 ; MIPS32-LABEL: select_float:
111 ; MIPS32: # %bb.0: # %entry
112 ; MIPS32-NEXT: andi $1, $4, 1
113 ; MIPS32-NEXT: mtc1 $5, $f1
114 ; MIPS32-NEXT: mtc1 $6, $f0
115 ; MIPS32-NEXT: movn.s $f0, $f1, $1
116 ; MIPS32-NEXT: jr $ra
119 %cond = select i1 %test, float %a, float %b
123 define void @select_ambiguous_float_in_gpr(i1 %test, float* %f32_ptr_a, float* %f32_ptr_b, float* %f32_ptr_c) {
124 ; MIPS32-LABEL: select_ambiguous_float_in_gpr:
125 ; MIPS32: # %bb.0: # %entry
126 ; MIPS32-NEXT: lw $2, 0($5)
127 ; MIPS32-NEXT: lw $1, 0($6)
128 ; MIPS32-NEXT: andi $3, $4, 1
129 ; MIPS32-NEXT: movn $1, $2, $3
130 ; MIPS32-NEXT: sw $1, 0($7)
131 ; MIPS32-NEXT: jr $ra
134 %0 = load float, float* %f32_ptr_a, align 4
135 %1 = load float, float* %f32_ptr_b, align 4
136 %cond = select i1 %test, float %0, float %1
137 store float %cond, float* %f32_ptr_c, align 4
141 define double @select_double(double %a, double %b, i1 %test) {
142 ; MIPS32-LABEL: select_double:
143 ; MIPS32: # %bb.0: # %entry
144 ; MIPS32-NEXT: mov.d $f0, $f14
145 ; MIPS32-NEXT: addiu $1, $sp, 16
146 ; MIPS32-NEXT: lw $1, 0($1)
147 ; MIPS32-NEXT: andi $1, $1, 1
148 ; MIPS32-NEXT: movn.d $f0, $f12, $1
149 ; MIPS32-NEXT: jr $ra
152 %cond = select i1 %test, double %a, double %b