Skip to content

Commit 23e9b49

Browse files
committed
[RISCV][GISel] Copy some Zba IR test cases from SelectionDAG. NFC
1 parent 949caf3 commit 23e9b49

File tree

2 files changed

+1854
-0
lines changed

2 files changed

+1854
-0
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
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
6+
7+
define signext i16 @sh1add(i64 %0, ptr %1) {
8+
; RV32I-LABEL: sh1add:
9+
; RV32I: # %bb.0:
10+
; RV32I-NEXT: slli a0, a0, 1
11+
; RV32I-NEXT: add a0, a2, a0
12+
; RV32I-NEXT: lh a0, 0(a0)
13+
; RV32I-NEXT: ret
14+
;
15+
; RV32ZBA-LABEL: sh1add:
16+
; RV32ZBA: # %bb.0:
17+
; RV32ZBA-NEXT: sh1add a0, a0, a2
18+
; RV32ZBA-NEXT: lh a0, 0(a0)
19+
; RV32ZBA-NEXT: ret
20+
%3 = getelementptr inbounds i16, ptr %1, i64 %0
21+
%4 = load i16, ptr %3
22+
ret i16 %4
23+
}
24+
25+
define i32 @sh2add(i64 %0, ptr %1) {
26+
; RV32I-LABEL: sh2add:
27+
; RV32I: # %bb.0:
28+
; RV32I-NEXT: slli a0, a0, 2
29+
; RV32I-NEXT: add a0, a2, a0
30+
; RV32I-NEXT: lw a0, 0(a0)
31+
; RV32I-NEXT: ret
32+
;
33+
; RV32ZBA-LABEL: sh2add:
34+
; RV32ZBA: # %bb.0:
35+
; RV32ZBA-NEXT: sh2add a0, a0, a2
36+
; RV32ZBA-NEXT: lw a0, 0(a0)
37+
; RV32ZBA-NEXT: ret
38+
%3 = getelementptr inbounds i32, ptr %1, i64 %0
39+
%4 = load i32, ptr %3
40+
ret i32 %4
41+
}
42+
43+
define i64 @sh3add(i64 %0, ptr %1) {
44+
; RV32I-LABEL: sh3add:
45+
; RV32I: # %bb.0:
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)
50+
; RV32I-NEXT: ret
51+
;
52+
; RV32ZBA-LABEL: sh3add:
53+
; RV32ZBA: # %bb.0:
54+
; RV32ZBA-NEXT: sh3add a1, a0, a2
55+
; RV32ZBA-NEXT: lw a0, 0(a1)
56+
; RV32ZBA-NEXT: lw a1, 4(a1)
57+
; RV32ZBA-NEXT: ret
58+
%3 = getelementptr inbounds i64, ptr %1, i64 %0
59+
%4 = load i64, ptr %3
60+
ret i64 %4
61+
}
62+
63+
define i32 @srli_1_sh2add(ptr %0, i32 %1) {
64+
; RV32I-LABEL: srli_1_sh2add:
65+
; RV32I: # %bb.0:
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)
70+
; RV32I-NEXT: ret
71+
;
72+
; RV32ZBA-LABEL: srli_1_sh2add:
73+
; RV32ZBA: # %bb.0:
74+
; RV32ZBA-NEXT: srli a1, a1, 1
75+
; RV32ZBA-NEXT: sh2add a0, a1, a0
76+
; RV32ZBA-NEXT: lw a0, 0(a0)
77+
; RV32ZBA-NEXT: ret
78+
%3 = lshr i32 %1, 1
79+
%4 = getelementptr inbounds i32, ptr %0, i32 %3
80+
%5 = load i32, ptr %4, align 4
81+
ret i32 %5
82+
}
83+
84+
define i64 @srli_2_sh3add(ptr %0, i32 %1) {
85+
; RV32I-LABEL: srli_2_sh3add:
86+
; RV32I: # %bb.0:
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)
92+
; RV32I-NEXT: ret
93+
;
94+
; RV32ZBA-LABEL: srli_2_sh3add:
95+
; RV32ZBA: # %bb.0:
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)
100+
; RV32ZBA-NEXT: ret
101+
%3 = lshr i32 %1, 2
102+
%4 = getelementptr inbounds i64, ptr %0, i32 %3
103+
%5 = load i64, ptr %4, align 8
104+
ret i64 %5
105+
}
106+
107+
define signext i16 @srli_2_sh1add(ptr %0, i32 %1) {
108+
; RV32I-LABEL: srli_2_sh1add:
109+
; RV32I: # %bb.0:
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)
114+
; RV32I-NEXT: ret
115+
;
116+
; RV32ZBA-LABEL: srli_2_sh1add:
117+
; RV32ZBA: # %bb.0:
118+
; RV32ZBA-NEXT: srli a1, a1, 2
119+
; RV32ZBA-NEXT: sh1add a0, a1, a0
120+
; RV32ZBA-NEXT: lh a0, 0(a0)
121+
; RV32ZBA-NEXT: ret
122+
%3 = lshr i32 %1, 2
123+
%4 = getelementptr inbounds i16, ptr %0, i32 %3
124+
%5 = load i16, ptr %4, align 2
125+
ret i16 %5
126+
}
127+
128+
define i32 @srli_3_sh2add(ptr %0, i32 %1) {
129+
; RV32I-LABEL: srli_3_sh2add:
130+
; RV32I: # %bb.0:
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)
135+
; RV32I-NEXT: ret
136+
;
137+
; RV32ZBA-LABEL: srli_3_sh2add:
138+
; RV32ZBA: # %bb.0:
139+
; RV32ZBA-NEXT: srli a1, a1, 3
140+
; RV32ZBA-NEXT: sh2add a0, a1, a0
141+
; RV32ZBA-NEXT: lw a0, 0(a0)
142+
; RV32ZBA-NEXT: ret
143+
%3 = lshr i32 %1, 3
144+
%4 = getelementptr inbounds i32, ptr %0, i32 %3
145+
%5 = load i32, ptr %4, align 4
146+
ret i32 %5
147+
}
148+
149+
define i64 @srli_4_sh3add(ptr %0, i32 %1) {
150+
; RV32I-LABEL: srli_4_sh3add:
151+
; RV32I: # %bb.0:
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)
157+
; RV32I-NEXT: ret
158+
;
159+
; RV32ZBA-LABEL: srli_4_sh3add:
160+
; RV32ZBA: # %bb.0:
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)
165+
; RV32ZBA-NEXT: ret
166+
%3 = lshr i32 %1, 4
167+
%4 = getelementptr inbounds i64, ptr %0, i32 %3
168+
%5 = load i64, ptr %4, align 8
169+
ret i64 %5
170+
}
171+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
172+
; CHECK: {{.*}}

0 commit comments

Comments
 (0)