1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -global-isel -mattr=+m -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefixes=CHECK,RV32I
4 ; RUN: llc -mtriple=riscv32 -global-isel -mattr=+m,+zba -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefixes=CHECK,RV32ZBA
7 define signext i16 @sh1add(i64 %0, ptr %1) {
10 ; RV32I-NEXT: slli a0, a0, 1
11 ; RV32I-NEXT: add a0, a2, a0
12 ; RV32I-NEXT: lh a0, 0(a0)
15 ; RV32ZBA-LABEL: sh1add:
17 ; RV32ZBA-NEXT: sh1add a0, a0, a2
18 ; RV32ZBA-NEXT: lh a0, 0(a0)
20 %3 = getelementptr inbounds i16, ptr %1, i64 %0
25 define i32 @sh2add(i64 %0, ptr %1) {
26 ; RV32I-LABEL: sh2add:
28 ; RV32I-NEXT: slli a0, a0, 2
29 ; RV32I-NEXT: add a0, a2, a0
30 ; RV32I-NEXT: lw a0, 0(a0)
33 ; RV32ZBA-LABEL: sh2add:
35 ; RV32ZBA-NEXT: sh2add a0, a0, a2
36 ; RV32ZBA-NEXT: lw a0, 0(a0)
38 %3 = getelementptr inbounds i32, ptr %1, i64 %0
43 define i64 @sh3add(i64 %0, ptr %1) {
44 ; RV32I-LABEL: sh3add:
46 ; RV32I-NEXT: slli a0, a0, 3
47 ; RV32I-NEXT: add a2, a2, a0
48 ; RV32I-NEXT: lw a0, 0(a2)
49 ; RV32I-NEXT: lw a1, 4(a2)
52 ; RV32ZBA-LABEL: sh3add:
54 ; RV32ZBA-NEXT: sh3add a1, a0, a2
55 ; RV32ZBA-NEXT: lw a0, 0(a1)
56 ; RV32ZBA-NEXT: lw a1, 4(a1)
58 %3 = getelementptr inbounds i64, ptr %1, i64 %0
63 define i32 @srli_1_sh2add(ptr %0, i32 %1) {
64 ; RV32I-LABEL: srli_1_sh2add:
66 ; RV32I-NEXT: srli a1, a1, 1
67 ; RV32I-NEXT: slli a1, a1, 2
68 ; RV32I-NEXT: add a0, a0, a1
69 ; RV32I-NEXT: lw a0, 0(a0)
72 ; RV32ZBA-LABEL: srli_1_sh2add:
74 ; RV32ZBA-NEXT: srli a1, a1, 1
75 ; RV32ZBA-NEXT: sh2add a0, a1, a0
76 ; RV32ZBA-NEXT: lw a0, 0(a0)
79 %4 = getelementptr inbounds i32, ptr %0, i32 %3
80 %5 = load i32, ptr %4, align 4
84 define i64 @srli_2_sh3add(ptr %0, i32 %1) {
85 ; RV32I-LABEL: srli_2_sh3add:
87 ; RV32I-NEXT: srli a1, a1, 2
88 ; RV32I-NEXT: slli a1, a1, 3
89 ; RV32I-NEXT: add a1, a0, a1
90 ; RV32I-NEXT: lw a0, 0(a1)
91 ; RV32I-NEXT: lw a1, 4(a1)
94 ; RV32ZBA-LABEL: srli_2_sh3add:
96 ; RV32ZBA-NEXT: srli a1, a1, 2
97 ; RV32ZBA-NEXT: sh3add a1, a1, a0
98 ; RV32ZBA-NEXT: lw a0, 0(a1)
99 ; RV32ZBA-NEXT: lw a1, 4(a1)
102 %4 = getelementptr inbounds i64, ptr %0, i32 %3
103 %5 = load i64, ptr %4, align 8
107 define signext i16 @srli_2_sh1add(ptr %0, i32 %1) {
108 ; RV32I-LABEL: srli_2_sh1add:
110 ; RV32I-NEXT: srli a1, a1, 2
111 ; RV32I-NEXT: slli a1, a1, 1
112 ; RV32I-NEXT: add a0, a0, a1
113 ; RV32I-NEXT: lh a0, 0(a0)
116 ; RV32ZBA-LABEL: srli_2_sh1add:
118 ; RV32ZBA-NEXT: srli a1, a1, 2
119 ; RV32ZBA-NEXT: sh1add a0, a1, a0
120 ; RV32ZBA-NEXT: lh a0, 0(a0)
123 %4 = getelementptr inbounds i16, ptr %0, i32 %3
124 %5 = load i16, ptr %4, align 2
128 define i32 @srli_3_sh2add(ptr %0, i32 %1) {
129 ; RV32I-LABEL: srli_3_sh2add:
131 ; RV32I-NEXT: srli a1, a1, 3
132 ; RV32I-NEXT: slli a1, a1, 2
133 ; RV32I-NEXT: add a0, a0, a1
134 ; RV32I-NEXT: lw a0, 0(a0)
137 ; RV32ZBA-LABEL: srli_3_sh2add:
139 ; RV32ZBA-NEXT: srli a1, a1, 3
140 ; RV32ZBA-NEXT: sh2add a0, a1, a0
141 ; RV32ZBA-NEXT: lw a0, 0(a0)
144 %4 = getelementptr inbounds i32, ptr %0, i32 %3
145 %5 = load i32, ptr %4, align 4
149 define i64 @srli_4_sh3add(ptr %0, i32 %1) {
150 ; RV32I-LABEL: srli_4_sh3add:
152 ; RV32I-NEXT: srli a1, a1, 4
153 ; RV32I-NEXT: slli a1, a1, 3
154 ; RV32I-NEXT: add a1, a0, a1
155 ; RV32I-NEXT: lw a0, 0(a1)
156 ; RV32I-NEXT: lw a1, 4(a1)
159 ; RV32ZBA-LABEL: srli_4_sh3add:
161 ; RV32ZBA-NEXT: srli a1, a1, 4
162 ; RV32ZBA-NEXT: sh3add a1, a1, a0
163 ; RV32ZBA-NEXT: lw a0, 0(a1)
164 ; RV32ZBA-NEXT: lw a1, 4(a1)
167 %4 = getelementptr inbounds i64, ptr %0, i32 %3
168 %5 = load i64, ptr %4, align 8
171 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: