1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s
4 declare void @llvm.loongarch.cacop.d(i64, i64, i64)
5 declare i32 @llvm.loongarch.crc.w.b.w(i32, i32)
6 declare i32 @llvm.loongarch.crc.w.h.w(i32, i32)
7 declare i32 @llvm.loongarch.crc.w.w.w(i32, i32)
8 declare i32 @llvm.loongarch.crc.w.d.w(i64, i32)
9 declare i32 @llvm.loongarch.crcc.w.b.w(i32, i32)
10 declare i32 @llvm.loongarch.crcc.w.h.w(i32, i32)
11 declare i32 @llvm.loongarch.crcc.w.w.w(i32, i32)
12 declare i32 @llvm.loongarch.crcc.w.d.w(i64, i32)
13 declare i64 @llvm.loongarch.csrrd.d(i32 immarg)
14 declare i64 @llvm.loongarch.csrwr.d(i64, i32 immarg)
15 declare i64 @llvm.loongarch.csrxchg.d(i64, i64, i32 immarg)
16 declare i64 @llvm.loongarch.iocsrrd.d(i32)
17 declare void @llvm.loongarch.iocsrwr.d(i64, i32)
18 declare void @llvm.loongarch.asrtle.d(i64, i64)
19 declare void @llvm.loongarch.asrtgt.d(i64, i64)
20 declare i64 @llvm.loongarch.lddir.d(i64, i64)
21 declare void @llvm.loongarch.ldpte.d(i64, i64)
23 define i32 @crc_w_b_w(i32 %a, i32 %b) nounwind {
24 ; CHECK-LABEL: crc_w_b_w:
26 ; CHECK-NEXT: crc.w.b.w $a0, $a0, $a1
28 %res = call i32 @llvm.loongarch.crc.w.b.w(i32 %a, i32 %b)
32 define void @crc_w_b_w_noret(i32 %a, i32 %b) nounwind {
33 ; CHECK-LABEL: crc_w_b_w_noret:
36 %res = call i32 @llvm.loongarch.crc.w.b.w(i32 %a, i32 %b)
40 define i32 @crc_w_h_w(i32 %a, i32 %b) nounwind {
41 ; CHECK-LABEL: crc_w_h_w:
43 ; CHECK-NEXT: crc.w.h.w $a0, $a0, $a1
45 %res = call i32 @llvm.loongarch.crc.w.h.w(i32 %a, i32 %b)
49 define void @crc_w_h_w_noret(i32 %a, i32 %b) nounwind {
50 ; CHECK-LABEL: crc_w_h_w_noret:
53 %res = call i32 @llvm.loongarch.crc.w.h.w(i32 %a, i32 %b)
57 define i32 @crc_w_w_w(i32 %a, i32 %b) nounwind {
58 ; CHECK-LABEL: crc_w_w_w:
60 ; CHECK-NEXT: crc.w.w.w $a0, $a0, $a1
62 %res = call i32 @llvm.loongarch.crc.w.w.w(i32 %a, i32 %b)
66 define void @crc_w_w_w_noret(i32 %a, i32 %b) nounwind {
67 ; CHECK-LABEL: crc_w_w_w_noret:
70 %res = call i32 @llvm.loongarch.crc.w.w.w(i32 %a, i32 %b)
74 define void @cacop_d(i64 %a) nounwind {
75 ; CHECK-LABEL: cacop_d:
77 ; CHECK-NEXT: cacop 1, $a0, 4
79 call void @llvm.loongarch.cacop.d(i64 1, i64 %a, i64 4)
83 define i32 @crc_w_d_w(i64 %a, i32 %b) nounwind {
84 ; CHECK-LABEL: crc_w_d_w:
86 ; CHECK-NEXT: crc.w.d.w $a0, $a0, $a1
88 %res = call i32 @llvm.loongarch.crc.w.d.w(i64 %a, i32 %b)
92 define void @crc_w_d_w_noret(i64 %a, i32 %b) nounwind {
93 ; CHECK-LABEL: crc_w_d_w_noret:
96 %res = call i32 @llvm.loongarch.crc.w.d.w(i64 %a, i32 %b)
100 define i32 @crcc_w_b_w(i32 %a, i32 %b) nounwind {
101 ; CHECK-LABEL: crcc_w_b_w:
103 ; CHECK-NEXT: crcc.w.b.w $a0, $a0, $a1
105 %res = call i32 @llvm.loongarch.crcc.w.b.w(i32 %a, i32 %b)
109 define void @crcc_w_b_w_noret(i32 %a, i32 %b) nounwind {
110 ; CHECK-LABEL: crcc_w_b_w_noret:
113 %res = call i32 @llvm.loongarch.crcc.w.b.w(i32 %a, i32 %b)
117 define i32 @crcc_w_h_w(i32 %a, i32 %b) nounwind {
118 ; CHECK-LABEL: crcc_w_h_w:
120 ; CHECK-NEXT: crcc.w.h.w $a0, $a0, $a1
122 %res = call i32 @llvm.loongarch.crcc.w.h.w(i32 %a, i32 %b)
126 define void @crcc_w_h_w_noret(i32 %a, i32 %b) nounwind {
127 ; CHECK-LABEL: crcc_w_h_w_noret:
130 %res = call i32 @llvm.loongarch.crcc.w.h.w(i32 %a, i32 %b)
134 define i32 @crcc_w_w_w(i32 %a, i32 %b) nounwind {
135 ; CHECK-LABEL: crcc_w_w_w:
137 ; CHECK-NEXT: crcc.w.w.w $a0, $a0, $a1
139 %res = call i32 @llvm.loongarch.crcc.w.w.w(i32 %a, i32 %b)
143 define void @crcc_w_w_w_noret(i32 %a, i32 %b) nounwind {
144 ; CHECK-LABEL: crcc_w_w_w_noret:
147 %res = call i32 @llvm.loongarch.crcc.w.w.w(i32 %a, i32 %b)
151 define i32 @crcc_w_d_w(i64 %a, i32 %b) nounwind {
152 ; CHECK-LABEL: crcc_w_d_w:
154 ; CHECK-NEXT: crcc.w.d.w $a0, $a0, $a1
156 %res = call i32 @llvm.loongarch.crcc.w.d.w(i64 %a, i32 %b)
160 define void @crcc_w_d_w_noret(i64 %a, i32 %b) nounwind {
161 ; CHECK-LABEL: crcc_w_d_w_noret:
164 %res = call i32 @llvm.loongarch.crcc.w.d.w(i64 %a, i32 %b)
168 define i64 @csrrd_d() {
169 ; CHECK-LABEL: csrrd_d:
170 ; CHECK: # %bb.0: # %entry
171 ; CHECK-NEXT: csrrd $a0, 1
174 %0 = tail call i64 @llvm.loongarch.csrrd.d(i32 1)
178 define void @csrrd_d_noret() {
179 ; CHECK-LABEL: csrrd_d_noret:
180 ; CHECK: # %bb.0: # %entry
181 ; CHECK-NEXT: csrrd $zero, 1
184 %0 = tail call i64 @llvm.loongarch.csrrd.d(i32 1)
188 define i64 @csrwr_d(i64 %a) {
189 ; CHECK-LABEL: csrwr_d:
190 ; CHECK: # %bb.0: # %entry
191 ; CHECK-NEXT: csrwr $a0, 1
194 %0 = tail call i64 @llvm.loongarch.csrwr.d(i64 %a, i32 1)
198 ;; Check that csrwr is emitted even if the return value of the intrinsic is not used.
199 define void @csrwr_d_noret(i64 %a) {
200 ; CHECK-LABEL: csrwr_d_noret:
201 ; CHECK: # %bb.0: # %entry
202 ; CHECK-NEXT: csrwr $a0, 1
205 %0 = tail call i64 @llvm.loongarch.csrwr.d(i64 %a, i32 1)
209 define i64 @csrxchg_d(i64 %a, i64 %b) {
210 ; CHECK-LABEL: csrxchg_d:
211 ; CHECK: # %bb.0: # %entry
212 ; CHECK-NEXT: csrxchg $a0, $a1, 1
215 %0 = tail call i64 @llvm.loongarch.csrxchg.d(i64 %a, i64 %b, i32 1)
219 ;; Check that csrxchg is emitted even if the return value of the intrinsic is not used.
220 define void @csrxchg_d_noret(i64 %a, i64 %b) {
221 ; CHECK-LABEL: csrxchg_d_noret:
222 ; CHECK: # %bb.0: # %entry
223 ; CHECK-NEXT: csrxchg $a0, $a1, 1
226 %0 = tail call i64 @llvm.loongarch.csrxchg.d(i64 %a, i64 %b, i32 1)
230 define i64 @iocsrrd_d(i32 %a) {
231 ; CHECK-LABEL: iocsrrd_d:
232 ; CHECK: # %bb.0: # %entry
233 ; CHECK-NEXT: iocsrrd.d $a0, $a0
236 %0 = tail call i64 @llvm.loongarch.iocsrrd.d(i32 %a)
240 define void @iocsrrd_d_noret(i32 %a) {
241 ; CHECK-LABEL: iocsrrd_d_noret:
242 ; CHECK: # %bb.0: # %entry
243 ; CHECK-NEXT: iocsrrd.d $zero, $a0
246 %0 = tail call i64 @llvm.loongarch.iocsrrd.d(i32 %a)
250 define void @iocsrwr_d(i64 %a, i32 signext %b) {
251 ; CHECK-LABEL: iocsrwr_d:
252 ; CHECK: # %bb.0: # %entry
253 ; CHECK-NEXT: iocsrwr.d $a0, $a1
256 tail call void @llvm.loongarch.iocsrwr.d(i64 %a, i32 %b)
260 define void @asrtle_d(i64 %a, i64 %b) {
261 ; CHECK-LABEL: asrtle_d:
262 ; CHECK: # %bb.0: # %entry
263 ; CHECK-NEXT: asrtle.d $a0, $a1
266 tail call void @llvm.loongarch.asrtle.d(i64 %a, i64 %b)
270 define void @asrtgt_d(i64 %a, i64 %b) {
271 ; CHECK-LABEL: asrtgt_d:
272 ; CHECK: # %bb.0: # %entry
273 ; CHECK-NEXT: asrtgt.d $a0, $a1
276 tail call void @llvm.loongarch.asrtgt.d(i64 %a, i64 %b)
280 define i64 @lddir_d(i64 %a) {
281 ; CHECK-LABEL: lddir_d:
282 ; CHECK: # %bb.0: # %entry
283 ; CHECK-NEXT: lddir $a0, $a0, 1
286 %0 = tail call i64 @llvm.loongarch.lddir.d(i64 %a, i64 1)
290 define void @lddir_d_noret(i64 %a) {
291 ; CHECK-LABEL: lddir_d_noret:
292 ; CHECK: # %bb.0: # %entry
293 ; CHECK-NEXT: lddir $zero, $a0, 1
296 %0 = tail call i64 @llvm.loongarch.lddir.d(i64 %a, i64 1)
300 define void @ldpte_d(i64 %a) {
301 ; CHECK-LABEL: ldpte_d:
302 ; CHECK: # %bb.0: # %entry
303 ; CHECK-NEXT: ldpte $a0, 1
306 tail call void @llvm.loongarch.ldpte.d(i64 %a, i64 1)