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: lui a1, 16
125 ; RV32I-NEXT: addi a1, a1, -64
126 ; RV32I-NEXT: and a0, a0, a1
127 ; RV32I-NEXT: srli a0, a0, 6
132 ; RV64I-NEXT: lui a1, 16
133 ; RV64I-NEXT: addiw a1, a1, -64
134 ; RV64I-NEXT: and a0, a0, a1
135 ; RV64I-NEXT: srli a0, a0, 6
141 define i16 @srai(i16 %a) nounwind {
144 ; RV32I-NEXT: slli a0, a0, 16
145 ; RV32I-NEXT: srai a0, a0, 25
150 ; RV64I-NEXT: slli a0, a0, 48
151 ; RV64I-NEXT: srai a0, a0, 57
158 define i16 @add(i16 %a, i16 %b) nounwind {
161 ; RV32I-NEXT: add a0, a0, a1
166 ; RV64I-NEXT: add a0, a0, a1
172 define i16 @sub(i16 %a, i16 %b) nounwind {
175 ; RV32I-NEXT: sub a0, a0, a1
180 ; RV64I-NEXT: sub a0, a0, a1
186 define i16 @sll(i16 %a, i16 %b) nounwind {
189 ; RV32I-NEXT: sll a0, a0, a1
194 ; RV64I-NEXT: sll a0, a0, a1
200 define i16 @slt(i16 %a, i16 %b) nounwind {
203 ; RV32I-NEXT: slli a1, a1, 16
204 ; RV32I-NEXT: srai a1, a1, 16
205 ; RV32I-NEXT: slli a0, a0, 16
206 ; RV32I-NEXT: srai a0, a0, 16
207 ; RV32I-NEXT: slt a0, a0, a1
212 ; RV64I-NEXT: slli a1, a1, 48
213 ; RV64I-NEXT: srai a1, a1, 48
214 ; RV64I-NEXT: slli a0, a0, 48
215 ; RV64I-NEXT: srai a0, a0, 48
216 ; RV64I-NEXT: slt a0, a0, a1
218 %1 = icmp slt i16 %a, %b
219 %2 = zext i1 %1 to i16
223 define i16 @sltu(i16 %a, i16 %b) nounwind {
226 ; RV32I-NEXT: lui a2, 16
227 ; RV32I-NEXT: addi a2, a2, -1
228 ; RV32I-NEXT: and a1, a1, a2
229 ; RV32I-NEXT: and a0, a0, a2
230 ; RV32I-NEXT: sltu a0, a0, a1
235 ; RV64I-NEXT: lui a2, 16
236 ; RV64I-NEXT: addiw a2, a2, -1
237 ; RV64I-NEXT: and a1, a1, a2
238 ; RV64I-NEXT: and a0, a0, a2
239 ; RV64I-NEXT: sltu a0, a0, a1
241 %1 = icmp ult i16 %a, %b
242 %2 = zext i1 %1 to i16
246 define i16 @xor(i16 %a, i16 %b) nounwind {
249 ; RV32I-NEXT: xor a0, a0, a1
254 ; RV64I-NEXT: xor a0, a0, a1
260 define i16 @srl(i16 %a, i16 %b) nounwind {
263 ; RV32I-NEXT: lui a2, 16
264 ; RV32I-NEXT: addi a2, a2, -1
265 ; RV32I-NEXT: and a0, a0, a2
266 ; RV32I-NEXT: srl a0, a0, a1
271 ; RV64I-NEXT: lui a2, 16
272 ; RV64I-NEXT: addiw a2, a2, -1
273 ; RV64I-NEXT: and a0, a0, a2
274 ; RV64I-NEXT: srl a0, a0, a1
280 define i16 @sra(i16 %a, i16 %b) nounwind {
283 ; RV32I-NEXT: slli a0, a0, 16
284 ; RV32I-NEXT: srai a0, a0, 16
285 ; RV32I-NEXT: sra a0, a0, a1
290 ; RV64I-NEXT: slli a0, a0, 48
291 ; RV64I-NEXT: srai a0, a0, 48
292 ; RV64I-NEXT: sra a0, a0, a1
298 define i16 @or(i16 %a, i16 %b) nounwind {
301 ; RV32I-NEXT: or a0, a0, a1
306 ; RV64I-NEXT: or a0, a0, a1
312 define i16 @and(i16 %a, i16 %b) nounwind {
315 ; RV32I-NEXT: and a0, a0, a1
320 ; RV64I-NEXT: and a0, a0, a1