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 i8. They check
8 ; that legalisation of these non-native types doesn't introduce unnecessary
11 define i8 @addi(i8 %a) nounwind {
14 ; RV32I-NEXT: addi a0, a0, 1
19 ; RV64I-NEXT: addi a0, a0, 1
25 define i8 @slti(i8 %a) nounwind {
28 ; RV32I-NEXT: slli a0, a0, 24
29 ; RV32I-NEXT: srai a0, a0, 24
30 ; RV32I-NEXT: slti a0, a0, 2
35 ; RV64I-NEXT: slli a0, a0, 56
36 ; RV64I-NEXT: srai a0, a0, 56
37 ; RV64I-NEXT: slti a0, a0, 2
39 %1 = icmp slt i8 %a, 2
44 define i8 @sltiu(i8 %a) nounwind {
47 ; RV32I-NEXT: andi a0, a0, 255
48 ; RV32I-NEXT: sltiu a0, a0, 3
53 ; RV64I-NEXT: andi a0, a0, 255
54 ; RV64I-NEXT: sltiu a0, a0, 3
56 %1 = icmp ult i8 %a, 3
61 ; Make sure we avoid an AND, if the input of an unsigned compare is known
62 ; to be sign extended. This can occur due to InstCombine canonicalizing
63 ; x s>= 0 && x s< 10 to x u< 10.
64 define i8 @sltiu_signext(i8 signext %a) nounwind {
65 ; RV32I-LABEL: sltiu_signext:
67 ; RV32I-NEXT: sltiu a0, a0, 10
70 ; RV64I-LABEL: sltiu_signext:
72 ; RV64I-NEXT: sltiu a0, a0, 10
74 %1 = icmp ult i8 %a, 10
79 define i8 @xori(i8 %a) nounwind {
82 ; RV32I-NEXT: xori a0, a0, 4
87 ; RV64I-NEXT: xori a0, a0, 4
93 define i8 @ori(i8 %a) nounwind {
96 ; RV32I-NEXT: ori a0, a0, 5
101 ; RV64I-NEXT: ori a0, a0, 5
107 define i8 @andi(i8 %a) nounwind {
110 ; RV32I-NEXT: andi a0, a0, 6
115 ; RV64I-NEXT: andi a0, a0, 6
121 define i8 @slli(i8 %a) nounwind {
124 ; RV32I-NEXT: slli a0, a0, 7
129 ; RV64I-NEXT: slli a0, a0, 7
135 define i8 @srli(i8 %a) nounwind {
138 ; RV32I-NEXT: slli a0, a0, 24
139 ; RV32I-NEXT: srli a0, a0, 30
144 ; RV64I-NEXT: slli a0, a0, 56
145 ; RV64I-NEXT: srli a0, a0, 62
151 define i8 @srai(i8 %a) nounwind {
154 ; RV32I-NEXT: slli a0, a0, 24
155 ; RV32I-NEXT: srai a0, a0, 29
160 ; RV64I-NEXT: slli a0, a0, 56
161 ; RV64I-NEXT: srai a0, a0, 61
168 define i8 @add(i8 %a, i8 %b) nounwind {
171 ; RV32I-NEXT: add a0, a0, a1
176 ; RV64I-NEXT: add a0, a0, a1
182 define i8 @sub(i8 %a, i8 %b) nounwind {
185 ; RV32I-NEXT: sub a0, a0, a1
190 ; RV64I-NEXT: sub a0, a0, a1
196 define i8 @sll(i8 %a, i8 %b) nounwind {
199 ; RV32I-NEXT: sll a0, a0, a1
204 ; RV64I-NEXT: sll a0, a0, a1
210 ; Test the pattern we get from C integer promotion.
211 define void @sll_ext(i8 %a, i32 signext %b, ptr %p) nounwind {
212 ; RV32I-LABEL: sll_ext:
214 ; RV32I-NEXT: sll a0, a0, a1
215 ; RV32I-NEXT: sb a0, 0(a2)
218 ; RV64I-LABEL: sll_ext:
220 ; RV64I-NEXT: sllw a0, a0, a1
221 ; RV64I-NEXT: sb a0, 0(a2)
223 %1 = zext i8 %a to i32
225 %3 = trunc i32 %2 to i8
230 ; Test the pattern we get from C integer promotion. This time with poison
232 define void @sll_ext_drop_poison(i8 %a, i32 signext %b, ptr %p) nounwind {
233 ; RV32I-LABEL: sll_ext_drop_poison:
235 ; RV32I-NEXT: sll a0, a0, a1
236 ; RV32I-NEXT: sb a0, 0(a2)
239 ; RV64I-LABEL: sll_ext_drop_poison:
241 ; RV64I-NEXT: sllw a0, a0, a1
242 ; RV64I-NEXT: sb a0, 0(a2)
244 %1 = zext i8 %a to i32
245 %2 = shl nuw nsw i32 %1, %b
246 %3 = trunc i32 %2 to i8
251 define i8 @slt(i8 %a, i8 %b) nounwind {
254 ; RV32I-NEXT: slli a1, a1, 24
255 ; RV32I-NEXT: srai a1, a1, 24
256 ; RV32I-NEXT: slli a0, a0, 24
257 ; RV32I-NEXT: srai a0, a0, 24
258 ; RV32I-NEXT: slt a0, a0, a1
263 ; RV64I-NEXT: slli a1, a1, 56
264 ; RV64I-NEXT: srai a1, a1, 56
265 ; RV64I-NEXT: slli a0, a0, 56
266 ; RV64I-NEXT: srai a0, a0, 56
267 ; RV64I-NEXT: slt a0, a0, a1
269 %1 = icmp slt i8 %a, %b
270 %2 = zext i1 %1 to i8
274 define i8 @sltu(i8 %a, i8 %b) nounwind {
277 ; RV32I-NEXT: andi a1, a1, 255
278 ; RV32I-NEXT: andi a0, a0, 255
279 ; RV32I-NEXT: sltu a0, a0, a1
284 ; RV64I-NEXT: andi a1, a1, 255
285 ; RV64I-NEXT: andi a0, a0, 255
286 ; RV64I-NEXT: sltu a0, a0, a1
288 %1 = icmp ult i8 %a, %b
289 %2 = zext i1 %1 to i8
293 define i8 @xor(i8 %a, i8 %b) nounwind {
296 ; RV32I-NEXT: xor a0, a0, a1
301 ; RV64I-NEXT: xor a0, a0, a1
307 define i8 @srl(i8 %a, i8 %b) nounwind {
310 ; RV32I-NEXT: andi a0, a0, 255
311 ; RV32I-NEXT: srl a0, a0, a1
316 ; RV64I-NEXT: andi a0, a0, 255
317 ; RV64I-NEXT: srl a0, a0, a1
323 define i8 @sra(i8 %a, i8 %b) nounwind {
326 ; RV32I-NEXT: slli a0, a0, 24
327 ; RV32I-NEXT: srai a0, a0, 24
328 ; RV32I-NEXT: sra a0, a0, a1
333 ; RV64I-NEXT: slli a0, a0, 56
334 ; RV64I-NEXT: srai a0, a0, 56
335 ; RV64I-NEXT: sra a0, a0, a1
341 define i8 @or(i8 %a, i8 %b) nounwind {
344 ; RV32I-NEXT: or a0, a0, a1
349 ; RV64I-NEXT: or a0, a0, a1
355 define i8 @and(i8 %a, i8 %b) nounwind {
358 ; RV32I-NEXT: and a0, a0, a1
363 ; RV64I-NEXT: and a0, a0, a1