blob: d179446b2c3021c820dd0b609d4d91e05edd0fbb [file] [log] [blame]
Vasileios Kalintirisa0520372016-02-01 15:19:35 +00001; RUN: llc < %s -march=mips -mcpu=mips2 | FileCheck %s \
2; RUN: -check-prefix=ALL -check-prefix=M2 -check-prefix=M2-M3
3; RUN: llc < %s -march=mips -mcpu=mips32 | FileCheck %s \
4; RUN: -check-prefix=ALL -check-prefix=CMOV \
5; RUN: -check-prefix=CMOV-32 -check-prefix=CMOV-32R1
6; RUN: llc < %s -march=mips -mcpu=mips32r2 | FileCheck %s \
7; RUN: -check-prefix=ALL -check-prefix=CMOV \
8; RUN: -check-prefix=CMOV-32 -check-prefix=CMOV-32R2-R5
9; RUN: llc < %s -march=mips -mcpu=mips32r3 | FileCheck %s \
10; RUN: -check-prefix=ALL -check-prefix=CMOV \
11; RUN: -check-prefix=CMOV-32 -check-prefix=CMOV-32R2-R5
12; RUN: llc < %s -march=mips -mcpu=mips32r5 | FileCheck %s \
13; RUN: -check-prefix=ALL -check-prefix=CMOV \
14; RUN: -check-prefix=CMOV-32 -check-prefix=CMOV-32R2-R5
15; RUN: llc < %s -march=mips -mcpu=mips32r6 | FileCheck %s \
16; RUN: -check-prefix=ALL -check-prefix=SEL -check-prefix=SEL-32
17; RUN: llc < %s -march=mips64 -mcpu=mips3 | FileCheck %s \
18; RUN: -check-prefix=ALL -check-prefix=M3 -check-prefix=M2-M3
19; RUN: llc < %s -march=mips64 -mcpu=mips4 | FileCheck %s \
20; RUN: -check-prefix=ALL -check-prefix=CMOV -check-prefix=CMOV-64
21; RUN: llc < %s -march=mips64 -mcpu=mips64 | FileCheck %s \
22; RUN: -check-prefix=ALL -check-prefix=CMOV -check-prefix=CMOV-64
23; RUN: llc < %s -march=mips64 -mcpu=mips64r2 | FileCheck %s \
24; RUN: -check-prefix=ALL -check-prefix=CMOV -check-prefix=CMOV-64
25; RUN: llc < %s -march=mips64 -mcpu=mips64r3 | FileCheck %s \
26; RUN: -check-prefix=ALL -check-prefix=CMOV -check-prefix=CMOV-64
27; RUN: llc < %s -march=mips64 -mcpu=mips64r5 | FileCheck %s \
28; RUN: -check-prefix=ALL -check-prefix=CMOV -check-prefix=CMOV-64
29; RUN: llc < %s -march=mips64 -mcpu=mips64r6 | FileCheck %s \
30; RUN: -check-prefix=ALL -check-prefix=SEL -check-prefix=SEL-64
31
Vasileios Kalintiris36901dd2016-03-01 20:25:43 +000032define signext i1 @tst_select_i1_i1(i1 signext %s,
33 i1 signext %x, i1 signext %y) {
Vasileios Kalintirisa0520372016-02-01 15:19:35 +000034entry:
35 ; ALL-LABEL: tst_select_i1_i1:
36
37 ; M2-M3: andi $[[T0:[0-9]+]], $4, 1
38 ; M2-M3: bnez $[[T0]], $[[BB0:BB[0-9_]+]]
39 ; M2-M3: nop
40 ; M2-M3: move $5, $6
41 ; M2-M3: $[[BB0]]:
42 ; M2-M3: jr $ra
43 ; M2-M3: move $2, $5
44
45 ; CMOV: andi $[[T0:[0-9]+]], $4, 1
46 ; CMOV: movn $6, $5, $[[T0]]
47 ; CMOV: move $2, $6
48
49 ; SEL: andi $[[T0:[0-9]+]], $4, 1
50 ; SEL: seleqz $[[T1:[0-9]+]], $6, $[[T0]]
51 ; SEL: selnez $[[T2:[0-9]+]], $5, $[[T0]]
52 ; SEL: or $2, $[[T2]], $[[T1]]
53 %r = select i1 %s, i1 %x, i1 %y
54 ret i1 %r
55}
56
Vasileios Kalintiris36901dd2016-03-01 20:25:43 +000057define signext i8 @tst_select_i1_i8(i1 signext %s,
58 i8 signext %x, i8 signext %y) {
Vasileios Kalintirisa0520372016-02-01 15:19:35 +000059entry:
60 ; ALL-LABEL: tst_select_i1_i8:
61
62 ; M2-M3: andi $[[T0:[0-9]+]], $4, 1
63 ; M2-M3: bnez $[[T0]], $[[BB0:BB[0-9_]+]]
64 ; M2-M3: nop
65 ; M2-M3: move $5, $6
66 ; M2-M3: $[[BB0]]:
67 ; M2-M3: jr $ra
68 ; M2-M3: move $2, $5
69
70 ; CMOV: andi $[[T0:[0-9]+]], $4, 1
71 ; CMOV: movn $6, $5, $[[T0]]
72 ; CMOV: move $2, $6
73
74 ; SEL: andi $[[T0:[0-9]+]], $4, 1
75 ; SEL: seleqz $[[T1:[0-9]+]], $6, $[[T0]]
76 ; SEL: selnez $[[T2:[0-9]+]], $5, $[[T0]]
77 ; SEL: or $2, $[[T2]], $[[T1]]
78 %r = select i1 %s, i8 %x, i8 %y
79 ret i8 %r
80}
81
Vasileios Kalintiris36901dd2016-03-01 20:25:43 +000082define signext i32 @tst_select_i1_i32(i1 signext %s,
83 i32 signext %x, i32 signext %y) {
Vasileios Kalintirisa0520372016-02-01 15:19:35 +000084entry:
85 ; ALL-LABEL: tst_select_i1_i32:
86
87 ; M2-M3: andi $[[T0:[0-9]+]], $4, 1
88 ; M2-M3: bnez $[[T0]], $[[BB0:BB[0-9_]+]]
89 ; M2-M3: nop
90 ; M2-M3: move $5, $6
91 ; M2-M3: $[[BB0]]:
92 ; M2-M3: jr $ra
93 ; M2-M3: move $2, $5
94
95 ; CMOV: andi $[[T0:[0-9]+]], $4, 1
96 ; CMOV: movn $6, $5, $[[T0]]
97 ; CMOV: move $2, $6
98
99 ; SEL: andi $[[T0:[0-9]+]], $4, 1
100 ; SEL: seleqz $[[T1:[0-9]+]], $6, $[[T0]]
101 ; SEL: selnez $[[T2:[0-9]+]], $5, $[[T0]]
102 ; SEL: or $2, $[[T2]], $[[T1]]
103 %r = select i1 %s, i32 %x, i32 %y
104 ret i32 %r
105}
106
Vasileios Kalintiris36901dd2016-03-01 20:25:43 +0000107define signext i64 @tst_select_i1_i64(i1 signext %s,
108 i64 signext %x, i64 signext %y) {
Vasileios Kalintirisa0520372016-02-01 15:19:35 +0000109entry:
110 ; ALL-LABEL: tst_select_i1_i64:
111
112 ; M2: andi $[[T0:[0-9]+]], $4, 1
113 ; M2: bnez $[[T0]], $[[BB0:BB[0-9_]+]]
114 ; M2: nop
115 ; M2: lw $[[T1:[0-9]+]], 16($sp)
116 ; M2: $[[BB0]]:
117 ; FIXME: This branch is redundant
118 ; M2: bnez $[[T0]], $[[BB1:BB[0-9_]+]]
119 ; M2: nop
120 ; M2: lw $[[T2:[0-9]+]], 20($sp)
121 ; M2: $[[BB1]]:
122 ; M2: move $2, $[[T1]]
123 ; M2: jr $ra
124 ; M2: move $3, $[[T2]]
125
126 ; CMOV-32: andi $[[T0:[0-9]+]], $4, 1
127 ; CMOV-32: lw $2, 16($sp)
128 ; CMOV-32: movn $2, $6, $[[T0]]
129 ; CMOV-32: lw $3, 20($sp)
130 ; CMOV-32: movn $3, $7, $[[T0]]
131
132 ; SEL-32: andi $[[T0:[0-9]+]], $4, 1
133 ; SEL-32: selnez $[[T1:[0-9]+]], $6, $[[T0]]
134 ; SEL-32: lw $[[T2:[0-9]+]], 16($sp)
135 ; SEL-32: seleqz $[[T3:[0-9]+]], $[[T2]], $[[T0]]
136 ; SEL-32: or $2, $[[T1]], $[[T3]]
137 ; SEL-32: selnez $[[T4:[0-9]+]], $7, $[[T0]]
138 ; SEL-32: lw $[[T5:[0-9]+]], 20($sp)
139 ; SEL-32: seleqz $[[T6:[0-9]+]], $[[T5]], $[[T0]]
140 ; SEL-32: or $3, $[[T4]], $[[T6]]
141
142 ; M3: andi $[[T0:[0-9]+]], $4, 1
143 ; M3: bnez $[[T0]], $[[BB0:BB[0-9_]+]]
144 ; M3: nop
145 ; M3: move $5, $6
146 ; M3: $[[BB0]]:
147 ; M3: jr $ra
148 ; M3: move $2, $5
149
150 ; CMOV-64: andi $[[T0:[0-9]+]], $4, 1
151 ; CMOV-64: movn $6, $5, $[[T0]]
152 ; CMOV-64: move $2, $6
153
154 ; SEL-64: andi $[[T0:[0-9]+]], $4, 1
Vasileios Kalintiris36901dd2016-03-01 20:25:43 +0000155 ; FIXME: This shift is redundant
156 ; SEL-64: sll $[[T0]], $[[T0]], 0
Vasileios Kalintirisa0520372016-02-01 15:19:35 +0000157 ; SEL-64: seleqz $[[T1:[0-9]+]], $6, $[[T0]]
158 ; SEL-64: selnez $[[T0]], $5, $[[T0]]
159 ; SEL-64: or $2, $[[T0]], $[[T1]]
160 %r = select i1 %s, i64 %x, i64 %y
161 ret i64 %r
162}
Simon Dardis5676d062016-04-22 13:19:22 +0000163
164define i8* @tst_select_word_cst(i8* %a, i8* %b) {
165 ; ALL-LABEL: tst_select_word_cst:
166
167 ; M2: addiu $1, $zero, -1
168 ; M2: xor $1, $5, $1
169 ; M2: sltu $1, $zero, $1
170 ; M2: bnez $1, $[[BB0:BB[0-9_]+]]
171 ; M2: addiu $2, $zero, 0
172 ; M2: move $2, $4
173 ; M2: $[[BB0]]:
174 ; M2: jr $ra
175
176 ; M3: daddiu $1, $zero, -1
177 ; M3: xor $1, $5, $1
178 ; M3: sltu $1, $zero, $1
179 ; M3: bnez $1, $[[BB0:BB[0-9_]+]]
180 ; M3: daddiu $2, $zero, 0
181 ; M3: move $2, $4
182 ; M3: $[[BB0]]:
183 ; M3: jr $ra
184
185 ; CMOV-32: addiu $1, $zero, -1
186 ; CMOV-32: xor $1, $5, $1
187 ; CMOV-32: movn $4, $zero, $1
188 ; CMOV-32: jr $ra
189 ; CMOV-32: move $2, $4
190
191 ; SEL-32: addiu $1, $zero, -1
192 ; SEL-32: xor $1, $5, $1
193 ; SEL-32: sltu $1, $zero, $1
194 ; SEL-32: jr $ra
195 ; SEL-32: seleqz $2, $4, $1
196
197 ; CMOV-64: daddiu $1, $zero, -1
198 ; CMOV-64: xor $1, $5, $1
199 ; CMOV-64: movn $4, $zero, $1
200 ; CMOV-64: move $2, $4
201
202 ; SEL-64: daddiu $1, $zero, -1
203 ; SEL-64: xor $1, $5, $1
204 ; SEL-64: sltu $1, $zero, $1
205 ; FIXME: This shift is redundant.
206 ; SEL-64: sll $1, $1, 0
207 ; SEL-64: seleqz $2, $4, $1
208
209 %cmp = icmp eq i8* %b, inttoptr (i64 -1 to i8*)
210 %r = select i1 %cmp, i8* %a, i8* null
211 ret i8* %r
212}