1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32I
4 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64I
7 ; These tests are identical to those in alu32.ll but operate on i16. They check
8 ; that legalisation of these non-native types doesn't introduce unnecessary
11 define i16 @addi(i16 %a) nounwind {
14 ; RV32I-NEXT: addi a0, a0, 1
19 ; RV64I-NEXT: addi a0, a0, 1
25 define i16 @slti(i16 %a) nounwind {
28 ; RV32I-NEXT: slli a0, a0, 16
29 ; RV32I-NEXT: srai a0, a0, 16
30 ; RV32I-NEXT: slti a0, a0, 2
35 ; RV64I-NEXT: slli a0, a0, 48
36 ; RV64I-NEXT: srai a0, a0, 48
37 ; RV64I-NEXT: slti a0, a0, 2
39 %1 = icmp slt i16 %a, 2
40 %2 = zext i1 %1 to i16
44 define i16 @sltiu(i16 %a) nounwind {
47 ; RV32I-NEXT: lui a1, 16
48 ; RV32I-NEXT: addi a1, a1, -1
49 ; RV32I-NEXT: and a0, a0, a1
50 ; RV32I-NEXT: sltiu a0, a0, 3
55 ; RV64I-NEXT: lui a1, 16
56 ; RV64I-NEXT: addiw a1, a1, -1
57 ; RV64I-NEXT: and a0, a0, a1
58 ; RV64I-NEXT: sltiu a0, a0, 3
60 %1 = icmp ult i16 %a, 3
61 %2 = zext i1 %1 to i16
65 define i16 @xori(i16 %a) nounwind {
68 ; RV32I-NEXT: xori a0, a0, 4
73 ; RV64I-NEXT: xori a0, a0, 4
79 define i16 @ori(i16 %a) nounwind {
82 ; RV32I-NEXT: ori a0, a0, 5
87 ; RV64I-NEXT: ori a0, a0, 5
93 define i16 @andi(i16 %a) nounwind {
96 ; RV32I-NEXT: andi a0, a0, 6
101 ; RV64I-NEXT: andi a0, a0, 6
107 define i16 @slli(i16 %a) nounwind {
110 ; RV32I-NEXT: slli a0, a0, 7
115 ; RV64I-NEXT: slli a0, a0, 7
121 define i16 @srli(i16 %a) nounwind {
124 ; RV32I-NEXT: slli a0, a0, 16
125 ; RV32I-NEXT: srli a0, a0, 22
130 ; RV64I-NEXT: slli a0, a0, 48
131 ; RV64I-NEXT: srli a0, a0, 54
137 define i16 @srai(i16 %a) nounwind {
140 ; RV32I-NEXT: slli a0, a0, 16
141 ; RV32I-NEXT: srai a0, a0, 25
146 ; RV64I-NEXT: slli a0, a0, 48
147 ; RV64I-NEXT: srai a0, a0, 57
154 define i16 @add(i16 %a, i16 %b) nounwind {
157 ; RV32I-NEXT: add a0, a0, a1
162 ; RV64I-NEXT: add a0, a0, a1
168 define i16 @sub(i16 %a, i16 %b) nounwind {
171 ; RV32I-NEXT: sub a0, a0, a1
176 ; RV64I-NEXT: sub a0, a0, a1
182 define i16 @sll(i16 %a, i16 %b) nounwind {
185 ; RV32I-NEXT: sll a0, a0, a1
190 ; RV64I-NEXT: sll a0, a0, a1
196 define i16 @slt(i16 %a, i16 %b) nounwind {
199 ; RV32I-NEXT: slli a1, a1, 16
200 ; RV32I-NEXT: srai a1, a1, 16
201 ; RV32I-NEXT: slli a0, a0, 16
202 ; RV32I-NEXT: srai a0, a0, 16
203 ; RV32I-NEXT: slt a0, a0, a1
208 ; RV64I-NEXT: slli a1, a1, 48
209 ; RV64I-NEXT: srai a1, a1, 48
210 ; RV64I-NEXT: slli a0, a0, 48
211 ; RV64I-NEXT: srai a0, a0, 48
212 ; RV64I-NEXT: slt a0, a0, a1
214 %1 = icmp slt i16 %a, %b
215 %2 = zext i1 %1 to i16
219 define i16 @sltu(i16 %a, i16 %b) nounwind {
222 ; RV32I-NEXT: lui a2, 16
223 ; RV32I-NEXT: addi a2, a2, -1
224 ; RV32I-NEXT: and a1, a1, a2
225 ; RV32I-NEXT: and a0, a0, a2
226 ; RV32I-NEXT: sltu a0, a0, a1
231 ; RV64I-NEXT: lui a2, 16
232 ; RV64I-NEXT: addiw a2, a2, -1
233 ; RV64I-NEXT: and a1, a1, a2
234 ; RV64I-NEXT: and a0, a0, a2
235 ; RV64I-NEXT: sltu a0, a0, a1
237 %1 = icmp ult i16 %a, %b
238 %2 = zext i1 %1 to i16
242 define i16 @xor(i16 %a, i16 %b) nounwind {
245 ; RV32I-NEXT: xor a0, a0, a1
250 ; RV64I-NEXT: xor a0, a0, a1
256 define i16 @srl(i16 %a, i16 %b) nounwind {
259 ; RV32I-NEXT: lui a2, 16
260 ; RV32I-NEXT: addi a2, a2, -1
261 ; RV32I-NEXT: and a0, a0, a2
262 ; RV32I-NEXT: srl a0, a0, a1
267 ; RV64I-NEXT: lui a2, 16
268 ; RV64I-NEXT: addiw a2, a2, -1
269 ; RV64I-NEXT: and a0, a0, a2
270 ; RV64I-NEXT: srl a0, a0, a1
276 define i16 @sra(i16 %a, i16 %b) nounwind {
279 ; RV32I-NEXT: slli a0, a0, 16
280 ; RV32I-NEXT: srai a0, a0, 16
281 ; RV32I-NEXT: sra a0, a0, a1
286 ; RV64I-NEXT: slli a0, a0, 48
287 ; RV64I-NEXT: srai a0, a0, 48
288 ; RV64I-NEXT: sra a0, a0, a1
294 define i16 @or(i16 %a, i16 %b) nounwind {
297 ; RV32I-NEXT: or a0, a0, a1
302 ; RV64I-NEXT: or a0, a0, a1
308 define i16 @and(i16 %a, i16 %b) nounwind {
311 ; RV32I-NEXT: and a0, a0, a1
316 ; RV64I-NEXT: and a0, a0, a1