• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
4define 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
10; MIPS32-NEXT:    jr $ra
11; MIPS32-NEXT:    nop
12entry:
13  %cond = select i1 %test, i8 %a, i8 %b
14  ret i8 %cond
15}
16
17define 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
23; MIPS32-NEXT:    jr $ra
24; MIPS32-NEXT:    nop
25entry:
26  %cond = select i1 %test, i16 %a, i16 %b
27  ret i16 %cond
28}
29
30define 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
36; MIPS32-NEXT:    jr $ra
37; MIPS32-NEXT:    nop
38entry:
39  %cond = select i1 %test, i32 %a, i32 %b
40  ret i32 %cond
41}
42
43define 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
49; MIPS32-NEXT:    jr $ra
50; MIPS32-NEXT:    nop
51entry:
52  %cond = select i1 %test, i32* %a, i32* %b
53  ret i32* %cond
54}
55
56define 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
65; MIPS32-NEXT:    jr $ra
66; MIPS32-NEXT:    nop
67entry:
68  %cmp = icmp slt i32 %a, %b
69  %lneg = xor i1 %cmp, true
70  %cond = select i1 %lneg, i32 %x, i32 %y
71  ret i32 %cond
72}
73
74define 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
84; MIPS32-NEXT:    jr $ra
85; MIPS32-NEXT:    nop
86entry:
87  %cond = select i1 %test, i64 %a, i64 %b
88  ret i64 %cond
89}
90
91define 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)
99; MIPS32-NEXT:    jr $ra
100; MIPS32-NEXT:    nop
101entry:
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
106  ret void
107}
108
109define 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
117; MIPS32-NEXT:    nop
118entry:
119  %cond = select i1 %test, float %a, float %b
120  ret float %cond
121}
122
123define 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
132; MIPS32-NEXT:    nop
133entry:
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
138  ret void
139}
140
141define 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
150; MIPS32-NEXT:    nop
151entry:
152  %cond = select i1 %test, double %a, double %b
153  ret double %cond
154}
155