xref: /llvm-project/llvm/test/CodeGen/RISCV/prefetch.ll (revision ff9af4c43ad71eeba2cabe99609cfaa0fd54c1d0)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3; RUN:   | FileCheck -check-prefix=RV32I %s
4; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
5; RUN:   | FileCheck -check-prefix=RV64I %s
6; RUN: llc -mtriple=riscv32 -mattr=+zicbop -verify-machineinstrs < %s \
7; RUN:   | FileCheck -check-prefix=RV32ZICBOP %s
8; RUN: llc -mtriple=riscv64 -mattr=+zicbop -verify-machineinstrs < %s \
9; RUN:   | FileCheck -check-prefix=RV64ZICBOP %s
10; RUN: llc -mtriple=riscv64 -mattr=+zicbop,+zihintntl -verify-machineinstrs < %s \
11; RUN:   | FileCheck -check-prefix=RV64ZICBOPZIHINTNTL %s
12
13declare void @llvm.prefetch(ptr, i32, i32, i32)
14
15define void @test_prefetch_read_locality_0(ptr %a) nounwind {
16; RV32I-LABEL: test_prefetch_read_locality_0:
17; RV32I:       # %bb.0:
18; RV32I-NEXT:    ret
19;
20; RV64I-LABEL: test_prefetch_read_locality_0:
21; RV64I:       # %bb.0:
22; RV64I-NEXT:    ret
23;
24; RV32ZICBOP-LABEL: test_prefetch_read_locality_0:
25; RV32ZICBOP:       # %bb.0:
26; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
27; RV32ZICBOP-NEXT:    ret
28;
29; RV64ZICBOP-LABEL: test_prefetch_read_locality_0:
30; RV64ZICBOP:       # %bb.0:
31; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
32; RV64ZICBOP-NEXT:    ret
33;
34; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_0:
35; RV64ZICBOPZIHINTNTL:       # %bb.0:
36; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
37; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
38; RV64ZICBOPZIHINTNTL-NEXT:    ret
39  call void @llvm.prefetch(ptr %a, i32 0, i32 0, i32 1)
40  ret void
41}
42
43define void @test_prefetch_write_locality_0(ptr %a) nounwind {
44; RV32I-LABEL: test_prefetch_write_locality_0:
45; RV32I:       # %bb.0:
46; RV32I-NEXT:    ret
47;
48; RV64I-LABEL: test_prefetch_write_locality_0:
49; RV64I:       # %bb.0:
50; RV64I-NEXT:    ret
51;
52; RV32ZICBOP-LABEL: test_prefetch_write_locality_0:
53; RV32ZICBOP:       # %bb.0:
54; RV32ZICBOP-NEXT:    prefetch.w 0(a0)
55; RV32ZICBOP-NEXT:    ret
56;
57; RV64ZICBOP-LABEL: test_prefetch_write_locality_0:
58; RV64ZICBOP:       # %bb.0:
59; RV64ZICBOP-NEXT:    prefetch.w 0(a0)
60; RV64ZICBOP-NEXT:    ret
61;
62; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_0:
63; RV64ZICBOPZIHINTNTL:       # %bb.0:
64; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
65; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.w 0(a0)
66; RV64ZICBOPZIHINTNTL-NEXT:    ret
67  call void @llvm.prefetch(ptr %a, i32 1, i32 0, i32 1)
68  ret void
69}
70
71define void @test_prefetch_instruction_locality_0(ptr %a) nounwind {
72; RV32I-LABEL: test_prefetch_instruction_locality_0:
73; RV32I:       # %bb.0:
74; RV32I-NEXT:    ret
75;
76; RV64I-LABEL: test_prefetch_instruction_locality_0:
77; RV64I:       # %bb.0:
78; RV64I-NEXT:    ret
79;
80; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_0:
81; RV32ZICBOP:       # %bb.0:
82; RV32ZICBOP-NEXT:    prefetch.i 0(a0)
83; RV32ZICBOP-NEXT:    ret
84;
85; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_0:
86; RV64ZICBOP:       # %bb.0:
87; RV64ZICBOP-NEXT:    prefetch.i 0(a0)
88; RV64ZICBOP-NEXT:    ret
89;
90; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_0:
91; RV64ZICBOPZIHINTNTL:       # %bb.0:
92; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
93; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.i 0(a0)
94; RV64ZICBOPZIHINTNTL-NEXT:    ret
95  call void @llvm.prefetch(ptr %a, i32 0, i32 0, i32 0)
96  ret void
97}
98
99define void @test_prefetch_read_locality_1(ptr %a) nounwind {
100; RV32I-LABEL: test_prefetch_read_locality_1:
101; RV32I:       # %bb.0:
102; RV32I-NEXT:    ret
103;
104; RV64I-LABEL: test_prefetch_read_locality_1:
105; RV64I:       # %bb.0:
106; RV64I-NEXT:    ret
107;
108; RV32ZICBOP-LABEL: test_prefetch_read_locality_1:
109; RV32ZICBOP:       # %bb.0:
110; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
111; RV32ZICBOP-NEXT:    ret
112;
113; RV64ZICBOP-LABEL: test_prefetch_read_locality_1:
114; RV64ZICBOP:       # %bb.0:
115; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
116; RV64ZICBOP-NEXT:    ret
117;
118; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_1:
119; RV64ZICBOPZIHINTNTL:       # %bb.0:
120; RV64ZICBOPZIHINTNTL-NEXT:    ntl.pall
121; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
122; RV64ZICBOPZIHINTNTL-NEXT:    ret
123  call void @llvm.prefetch(ptr %a, i32 0, i32 1, i32 1)
124  ret void
125}
126
127define void @test_prefetch_write_locality_1(ptr %a) nounwind {
128; RV32I-LABEL: test_prefetch_write_locality_1:
129; RV32I:       # %bb.0:
130; RV32I-NEXT:    ret
131;
132; RV64I-LABEL: test_prefetch_write_locality_1:
133; RV64I:       # %bb.0:
134; RV64I-NEXT:    ret
135;
136; RV32ZICBOP-LABEL: test_prefetch_write_locality_1:
137; RV32ZICBOP:       # %bb.0:
138; RV32ZICBOP-NEXT:    prefetch.w 0(a0)
139; RV32ZICBOP-NEXT:    ret
140;
141; RV64ZICBOP-LABEL: test_prefetch_write_locality_1:
142; RV64ZICBOP:       # %bb.0:
143; RV64ZICBOP-NEXT:    prefetch.w 0(a0)
144; RV64ZICBOP-NEXT:    ret
145;
146; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_1:
147; RV64ZICBOPZIHINTNTL:       # %bb.0:
148; RV64ZICBOPZIHINTNTL-NEXT:    ntl.pall
149; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.w 0(a0)
150; RV64ZICBOPZIHINTNTL-NEXT:    ret
151  call void @llvm.prefetch(ptr %a, i32 1, i32 1, i32 1)
152  ret void
153}
154
155define void @test_prefetch_instruction_locality_1(ptr %a) nounwind {
156; RV32I-LABEL: test_prefetch_instruction_locality_1:
157; RV32I:       # %bb.0:
158; RV32I-NEXT:    ret
159;
160; RV64I-LABEL: test_prefetch_instruction_locality_1:
161; RV64I:       # %bb.0:
162; RV64I-NEXT:    ret
163;
164; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_1:
165; RV32ZICBOP:       # %bb.0:
166; RV32ZICBOP-NEXT:    prefetch.i 0(a0)
167; RV32ZICBOP-NEXT:    ret
168;
169; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_1:
170; RV64ZICBOP:       # %bb.0:
171; RV64ZICBOP-NEXT:    prefetch.i 0(a0)
172; RV64ZICBOP-NEXT:    ret
173;
174; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_1:
175; RV64ZICBOPZIHINTNTL:       # %bb.0:
176; RV64ZICBOPZIHINTNTL-NEXT:    ntl.pall
177; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.i 0(a0)
178; RV64ZICBOPZIHINTNTL-NEXT:    ret
179  call void @llvm.prefetch(ptr %a, i32 0, i32 1, i32 0)
180  ret void
181}
182
183define void @test_prefetch_read_locality_2(ptr %a) nounwind {
184; RV32I-LABEL: test_prefetch_read_locality_2:
185; RV32I:       # %bb.0:
186; RV32I-NEXT:    ret
187;
188; RV64I-LABEL: test_prefetch_read_locality_2:
189; RV64I:       # %bb.0:
190; RV64I-NEXT:    ret
191;
192; RV32ZICBOP-LABEL: test_prefetch_read_locality_2:
193; RV32ZICBOP:       # %bb.0:
194; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
195; RV32ZICBOP-NEXT:    ret
196;
197; RV64ZICBOP-LABEL: test_prefetch_read_locality_2:
198; RV64ZICBOP:       # %bb.0:
199; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
200; RV64ZICBOP-NEXT:    ret
201;
202; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_2:
203; RV64ZICBOPZIHINTNTL:       # %bb.0:
204; RV64ZICBOPZIHINTNTL-NEXT:    ntl.p1
205; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
206; RV64ZICBOPZIHINTNTL-NEXT:    ret
207  call void @llvm.prefetch(ptr %a, i32 0, i32 2, i32 1)
208  ret void
209}
210
211define void @test_prefetch_write_locality_2(ptr %a) nounwind {
212; RV32I-LABEL: test_prefetch_write_locality_2:
213; RV32I:       # %bb.0:
214; RV32I-NEXT:    ret
215;
216; RV64I-LABEL: test_prefetch_write_locality_2:
217; RV64I:       # %bb.0:
218; RV64I-NEXT:    ret
219;
220; RV32ZICBOP-LABEL: test_prefetch_write_locality_2:
221; RV32ZICBOP:       # %bb.0:
222; RV32ZICBOP-NEXT:    prefetch.w 0(a0)
223; RV32ZICBOP-NEXT:    ret
224;
225; RV64ZICBOP-LABEL: test_prefetch_write_locality_2:
226; RV64ZICBOP:       # %bb.0:
227; RV64ZICBOP-NEXT:    prefetch.w 0(a0)
228; RV64ZICBOP-NEXT:    ret
229;
230; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_2:
231; RV64ZICBOPZIHINTNTL:       # %bb.0:
232; RV64ZICBOPZIHINTNTL-NEXT:    ntl.p1
233; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.w 0(a0)
234; RV64ZICBOPZIHINTNTL-NEXT:    ret
235  call void @llvm.prefetch(ptr %a, i32 1, i32 2, i32 1)
236  ret void
237}
238
239define void @test_prefetch_instruction_locality_2(ptr %a) nounwind {
240; RV32I-LABEL: test_prefetch_instruction_locality_2:
241; RV32I:       # %bb.0:
242; RV32I-NEXT:    ret
243;
244; RV64I-LABEL: test_prefetch_instruction_locality_2:
245; RV64I:       # %bb.0:
246; RV64I-NEXT:    ret
247;
248; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_2:
249; RV32ZICBOP:       # %bb.0:
250; RV32ZICBOP-NEXT:    prefetch.i 0(a0)
251; RV32ZICBOP-NEXT:    ret
252;
253; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_2:
254; RV64ZICBOP:       # %bb.0:
255; RV64ZICBOP-NEXT:    prefetch.i 0(a0)
256; RV64ZICBOP-NEXT:    ret
257;
258; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_2:
259; RV64ZICBOPZIHINTNTL:       # %bb.0:
260; RV64ZICBOPZIHINTNTL-NEXT:    ntl.p1
261; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.i 0(a0)
262; RV64ZICBOPZIHINTNTL-NEXT:    ret
263  call void @llvm.prefetch(ptr %a, i32 0, i32 2, i32 0)
264  ret void
265}
266
267
268define void @test_prefetch_read_locality_3(ptr %a) nounwind {
269; RV32I-LABEL: test_prefetch_read_locality_3:
270; RV32I:       # %bb.0:
271; RV32I-NEXT:    ret
272;
273; RV64I-LABEL: test_prefetch_read_locality_3:
274; RV64I:       # %bb.0:
275; RV64I-NEXT:    ret
276;
277; RV32ZICBOP-LABEL: test_prefetch_read_locality_3:
278; RV32ZICBOP:       # %bb.0:
279; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
280; RV32ZICBOP-NEXT:    ret
281;
282; RV64ZICBOP-LABEL: test_prefetch_read_locality_3:
283; RV64ZICBOP:       # %bb.0:
284; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
285; RV64ZICBOP-NEXT:    ret
286;
287; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_3:
288; RV64ZICBOPZIHINTNTL:       # %bb.0:
289; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
290; RV64ZICBOPZIHINTNTL-NEXT:    ret
291  call void @llvm.prefetch(ptr %a, i32 0, i32 3, i32 1)
292  ret void
293}
294
295define void @test_prefetch_write_locality_3(ptr %a) nounwind {
296; RV32I-LABEL: test_prefetch_write_locality_3:
297; RV32I:       # %bb.0:
298; RV32I-NEXT:    ret
299;
300; RV64I-LABEL: test_prefetch_write_locality_3:
301; RV64I:       # %bb.0:
302; RV64I-NEXT:    ret
303;
304; RV32ZICBOP-LABEL: test_prefetch_write_locality_3:
305; RV32ZICBOP:       # %bb.0:
306; RV32ZICBOP-NEXT:    prefetch.w 0(a0)
307; RV32ZICBOP-NEXT:    ret
308;
309; RV64ZICBOP-LABEL: test_prefetch_write_locality_3:
310; RV64ZICBOP:       # %bb.0:
311; RV64ZICBOP-NEXT:    prefetch.w 0(a0)
312; RV64ZICBOP-NEXT:    ret
313;
314; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_3:
315; RV64ZICBOPZIHINTNTL:       # %bb.0:
316; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.w 0(a0)
317; RV64ZICBOPZIHINTNTL-NEXT:    ret
318  call void @llvm.prefetch(ptr %a, i32 1, i32 3, i32 1)
319  ret void
320}
321
322define void @test_prefetch_instruction_locality_3(ptr %a) nounwind {
323; RV32I-LABEL: test_prefetch_instruction_locality_3:
324; RV32I:       # %bb.0:
325; RV32I-NEXT:    ret
326;
327; RV64I-LABEL: test_prefetch_instruction_locality_3:
328; RV64I:       # %bb.0:
329; RV64I-NEXT:    ret
330;
331; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_3:
332; RV32ZICBOP:       # %bb.0:
333; RV32ZICBOP-NEXT:    prefetch.i 0(a0)
334; RV32ZICBOP-NEXT:    ret
335;
336; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_3:
337; RV64ZICBOP:       # %bb.0:
338; RV64ZICBOP-NEXT:    prefetch.i 0(a0)
339; RV64ZICBOP-NEXT:    ret
340;
341; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_3:
342; RV64ZICBOPZIHINTNTL:       # %bb.0:
343; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.i 0(a0)
344; RV64ZICBOPZIHINTNTL-NEXT:    ret
345  call void @llvm.prefetch(ptr %a, i32 0, i32 3, i32 0)
346  ret void
347}
348
349define void @test_prefetch_offsetable_0(ptr %a) nounwind {
350; RV32I-LABEL: test_prefetch_offsetable_0:
351; RV32I:       # %bb.0:
352; RV32I-NEXT:    ret
353;
354; RV64I-LABEL: test_prefetch_offsetable_0:
355; RV64I:       # %bb.0:
356; RV64I-NEXT:    ret
357;
358; RV32ZICBOP-LABEL: test_prefetch_offsetable_0:
359; RV32ZICBOP:       # %bb.0:
360; RV32ZICBOP-NEXT:    prefetch.r 2016(a0)
361; RV32ZICBOP-NEXT:    ret
362;
363; RV64ZICBOP-LABEL: test_prefetch_offsetable_0:
364; RV64ZICBOP:       # %bb.0:
365; RV64ZICBOP-NEXT:    prefetch.r 2016(a0)
366; RV64ZICBOP-NEXT:    ret
367;
368; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_0:
369; RV64ZICBOPZIHINTNTL:       # %bb.0:
370; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
371; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 2016(a0)
372; RV64ZICBOPZIHINTNTL-NEXT:    ret
373  %addr = getelementptr i8, ptr %a, i64 2016
374  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
375  ret void
376}
377
378define void @test_prefetch_offsetable_1(ptr %a) nounwind {
379; RV32I-LABEL: test_prefetch_offsetable_1:
380; RV32I:       # %bb.0:
381; RV32I-NEXT:    ret
382;
383; RV64I-LABEL: test_prefetch_offsetable_1:
384; RV64I:       # %bb.0:
385; RV64I-NEXT:    ret
386;
387; RV32ZICBOP-LABEL: test_prefetch_offsetable_1:
388; RV32ZICBOP:       # %bb.0:
389; RV32ZICBOP-NEXT:    prefetch.r -2048(a0)
390; RV32ZICBOP-NEXT:    ret
391;
392; RV64ZICBOP-LABEL: test_prefetch_offsetable_1:
393; RV64ZICBOP:       # %bb.0:
394; RV64ZICBOP-NEXT:    prefetch.r -2048(a0)
395; RV64ZICBOP-NEXT:    ret
396;
397; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_1:
398; RV64ZICBOPZIHINTNTL:       # %bb.0:
399; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
400; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -2048(a0)
401; RV64ZICBOPZIHINTNTL-NEXT:    ret
402  %addr = getelementptr i8, ptr %a, i64 -2048
403  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
404  ret void
405}
406
407define void @test_prefetch_offsetable_2(ptr %a) nounwind {
408; RV32I-LABEL: test_prefetch_offsetable_2:
409; RV32I:       # %bb.0:
410; RV32I-NEXT:    ret
411;
412; RV64I-LABEL: test_prefetch_offsetable_2:
413; RV64I:       # %bb.0:
414; RV64I-NEXT:    ret
415;
416; RV32ZICBOP-LABEL: test_prefetch_offsetable_2:
417; RV32ZICBOP:       # %bb.0:
418; RV32ZICBOP-NEXT:    prefetch.r 32(a0)
419; RV32ZICBOP-NEXT:    ret
420;
421; RV64ZICBOP-LABEL: test_prefetch_offsetable_2:
422; RV64ZICBOP:       # %bb.0:
423; RV64ZICBOP-NEXT:    prefetch.r 32(a0)
424; RV64ZICBOP-NEXT:    ret
425;
426; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_2:
427; RV64ZICBOPZIHINTNTL:       # %bb.0:
428; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
429; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 32(a0)
430; RV64ZICBOPZIHINTNTL-NEXT:    ret
431  %addr = getelementptr i8, ptr %a, i64 32
432  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
433  ret void
434}
435
436define void @test_prefetch_offsetable_3(ptr %a) nounwind {
437; RV32I-LABEL: test_prefetch_offsetable_3:
438; RV32I:       # %bb.0:
439; RV32I-NEXT:    ret
440;
441; RV64I-LABEL: test_prefetch_offsetable_3:
442; RV64I:       # %bb.0:
443; RV64I-NEXT:    ret
444;
445; RV32ZICBOP-LABEL: test_prefetch_offsetable_3:
446; RV32ZICBOP:       # %bb.0:
447; RV32ZICBOP-NEXT:    prefetch.r -32(a0)
448; RV32ZICBOP-NEXT:    ret
449;
450; RV64ZICBOP-LABEL: test_prefetch_offsetable_3:
451; RV64ZICBOP:       # %bb.0:
452; RV64ZICBOP-NEXT:    prefetch.r -32(a0)
453; RV64ZICBOP-NEXT:    ret
454;
455; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_3:
456; RV64ZICBOPZIHINTNTL:       # %bb.0:
457; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
458; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -32(a0)
459; RV64ZICBOPZIHINTNTL-NEXT:    ret
460  %addr = getelementptr i8, ptr %a, i64 -32
461  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
462  ret void
463}
464
465define void @test_prefetch_offsetable_4(ptr %a) nounwind {
466; RV32I-LABEL: test_prefetch_offsetable_4:
467; RV32I:       # %bb.0:
468; RV32I-NEXT:    ret
469;
470; RV64I-LABEL: test_prefetch_offsetable_4:
471; RV64I:       # %bb.0:
472; RV64I-NEXT:    ret
473;
474; RV32ZICBOP-LABEL: test_prefetch_offsetable_4:
475; RV32ZICBOP:       # %bb.0:
476; RV32ZICBOP-NEXT:    addi a0, a0, 32
477; RV32ZICBOP-NEXT:    prefetch.r 2016(a0)
478; RV32ZICBOP-NEXT:    ret
479;
480; RV64ZICBOP-LABEL: test_prefetch_offsetable_4:
481; RV64ZICBOP:       # %bb.0:
482; RV64ZICBOP-NEXT:    addi a0, a0, 32
483; RV64ZICBOP-NEXT:    prefetch.r 2016(a0)
484; RV64ZICBOP-NEXT:    ret
485;
486; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_4:
487; RV64ZICBOPZIHINTNTL:       # %bb.0:
488; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, 32
489; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
490; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 2016(a0)
491; RV64ZICBOPZIHINTNTL-NEXT:    ret
492  %addr = getelementptr i8, ptr %a, i64 2048
493  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
494  ret void
495}
496
497define void @test_prefetch_offsetable_5(ptr %a) nounwind {
498; RV32I-LABEL: test_prefetch_offsetable_5:
499; RV32I:       # %bb.0:
500; RV32I-NEXT:    ret
501;
502; RV64I-LABEL: test_prefetch_offsetable_5:
503; RV64I:       # %bb.0:
504; RV64I-NEXT:    ret
505;
506; RV32ZICBOP-LABEL: test_prefetch_offsetable_5:
507; RV32ZICBOP:       # %bb.0:
508; RV32ZICBOP-NEXT:    addi a0, a0, -1
509; RV32ZICBOP-NEXT:    prefetch.r -2048(a0)
510; RV32ZICBOP-NEXT:    ret
511;
512; RV64ZICBOP-LABEL: test_prefetch_offsetable_5:
513; RV64ZICBOP:       # %bb.0:
514; RV64ZICBOP-NEXT:    addi a0, a0, -1
515; RV64ZICBOP-NEXT:    prefetch.r -2048(a0)
516; RV64ZICBOP-NEXT:    ret
517;
518; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_5:
519; RV64ZICBOPZIHINTNTL:       # %bb.0:
520; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, -1
521; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
522; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -2048(a0)
523; RV64ZICBOPZIHINTNTL-NEXT:    ret
524  %addr = getelementptr i8, ptr %a, i64 -2049
525  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
526  ret void
527}
528
529define void @test_prefetch_offsetable_6(ptr %a) nounwind {
530; RV32I-LABEL: test_prefetch_offsetable_6:
531; RV32I:       # %bb.0:
532; RV32I-NEXT:    ret
533;
534; RV64I-LABEL: test_prefetch_offsetable_6:
535; RV64I:       # %bb.0:
536; RV64I-NEXT:    ret
537;
538; RV32ZICBOP-LABEL: test_prefetch_offsetable_6:
539; RV32ZICBOP:       # %bb.0:
540; RV32ZICBOP-NEXT:    addi a0, a0, 16
541; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
542; RV32ZICBOP-NEXT:    ret
543;
544; RV64ZICBOP-LABEL: test_prefetch_offsetable_6:
545; RV64ZICBOP:       # %bb.0:
546; RV64ZICBOP-NEXT:    addi a0, a0, 16
547; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
548; RV64ZICBOP-NEXT:    ret
549;
550; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_6:
551; RV64ZICBOPZIHINTNTL:       # %bb.0:
552; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, 16
553; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
554; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
555; RV64ZICBOPZIHINTNTL-NEXT:    ret
556  %addr = getelementptr i8, ptr %a, i64 16
557  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
558  ret void
559}
560
561define void @test_prefetch_offsetable_7(ptr %a) nounwind {
562; RV32I-LABEL: test_prefetch_offsetable_7:
563; RV32I:       # %bb.0:
564; RV32I-NEXT:    ret
565;
566; RV64I-LABEL: test_prefetch_offsetable_7:
567; RV64I:       # %bb.0:
568; RV64I-NEXT:    ret
569;
570; RV32ZICBOP-LABEL: test_prefetch_offsetable_7:
571; RV32ZICBOP:       # %bb.0:
572; RV32ZICBOP-NEXT:    addi a0, a0, -16
573; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
574; RV32ZICBOP-NEXT:    ret
575;
576; RV64ZICBOP-LABEL: test_prefetch_offsetable_7:
577; RV64ZICBOP:       # %bb.0:
578; RV64ZICBOP-NEXT:    addi a0, a0, -16
579; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
580; RV64ZICBOP-NEXT:    ret
581;
582; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_7:
583; RV64ZICBOPZIHINTNTL:       # %bb.0:
584; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, -16
585; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
586; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
587; RV64ZICBOPZIHINTNTL-NEXT:    ret
588  %addr = getelementptr i8, ptr %a, i64 -16
589  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
590  ret void
591}
592
593define void @test_prefetch_offsetable_9(ptr %a) nounwind {
594; RV32I-LABEL: test_prefetch_offsetable_9:
595; RV32I:       # %bb.0:
596; RV32I-NEXT:    ret
597;
598; RV64I-LABEL: test_prefetch_offsetable_9:
599; RV64I:       # %bb.0:
600; RV64I-NEXT:    ret
601;
602; RV32ZICBOP-LABEL: test_prefetch_offsetable_9:
603; RV32ZICBOP:       # %bb.0:
604; RV32ZICBOP-NEXT:    lui a1, 1
605; RV32ZICBOP-NEXT:    add a0, a0, a1
606; RV32ZICBOP-NEXT:    prefetch.r 64(a0)
607; RV32ZICBOP-NEXT:    ret
608;
609; RV64ZICBOP-LABEL: test_prefetch_offsetable_9:
610; RV64ZICBOP:       # %bb.0:
611; RV64ZICBOP-NEXT:    lui a1, 1
612; RV64ZICBOP-NEXT:    add a0, a0, a1
613; RV64ZICBOP-NEXT:    prefetch.r 64(a0)
614; RV64ZICBOP-NEXT:    ret
615;
616; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_9:
617; RV64ZICBOPZIHINTNTL:       # %bb.0:
618; RV64ZICBOPZIHINTNTL-NEXT:    lui a1, 1
619; RV64ZICBOPZIHINTNTL-NEXT:    add a0, a0, a1
620; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
621; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 64(a0)
622; RV64ZICBOPZIHINTNTL-NEXT:    ret
623  %addr = getelementptr i8, ptr %a, i64 4160
624  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
625  ret void
626}
627
628define void @test_prefetch_offsetable_8(ptr %a) nounwind {
629; RV32I-LABEL: test_prefetch_offsetable_8:
630; RV32I:       # %bb.0:
631; RV32I-NEXT:    ret
632;
633; RV64I-LABEL: test_prefetch_offsetable_8:
634; RV64I:       # %bb.0:
635; RV64I-NEXT:    ret
636;
637; RV32ZICBOP-LABEL: test_prefetch_offsetable_8:
638; RV32ZICBOP:       # %bb.0:
639; RV32ZICBOP-NEXT:    lui a1, 1048575
640; RV32ZICBOP-NEXT:    add a0, a0, a1
641; RV32ZICBOP-NEXT:    prefetch.r -64(a0)
642; RV32ZICBOP-NEXT:    ret
643;
644; RV64ZICBOP-LABEL: test_prefetch_offsetable_8:
645; RV64ZICBOP:       # %bb.0:
646; RV64ZICBOP-NEXT:    lui a1, 1048575
647; RV64ZICBOP-NEXT:    add a0, a0, a1
648; RV64ZICBOP-NEXT:    prefetch.r -64(a0)
649; RV64ZICBOP-NEXT:    ret
650;
651; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_offsetable_8:
652; RV64ZICBOPZIHINTNTL:       # %bb.0:
653; RV64ZICBOPZIHINTNTL-NEXT:    lui a1, 1048575
654; RV64ZICBOPZIHINTNTL-NEXT:    add a0, a0, a1
655; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
656; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -64(a0)
657; RV64ZICBOPZIHINTNTL-NEXT:    ret
658  %addr = getelementptr i8, ptr %a, i64 -4160
659  call void @llvm.prefetch(ptr %addr, i32 0, i32 0, i32 1)
660  ret void
661}
662
663define void @test_prefetch_frameindex_0() nounwind {
664; RV32I-LABEL: test_prefetch_frameindex_0:
665; RV32I:       # %bb.0:
666; RV32I-NEXT:    addi sp, sp, -512
667; RV32I-NEXT:    addi sp, sp, 512
668; RV32I-NEXT:    ret
669;
670; RV64I-LABEL: test_prefetch_frameindex_0:
671; RV64I:       # %bb.0:
672; RV64I-NEXT:    addi sp, sp, -512
673; RV64I-NEXT:    addi sp, sp, 512
674; RV64I-NEXT:    ret
675;
676; RV32ZICBOP-LABEL: test_prefetch_frameindex_0:
677; RV32ZICBOP:       # %bb.0:
678; RV32ZICBOP-NEXT:    addi sp, sp, -512
679; RV32ZICBOP-NEXT:    prefetch.r 0(sp)
680; RV32ZICBOP-NEXT:    addi sp, sp, 512
681; RV32ZICBOP-NEXT:    ret
682;
683; RV64ZICBOP-LABEL: test_prefetch_frameindex_0:
684; RV64ZICBOP:       # %bb.0:
685; RV64ZICBOP-NEXT:    addi sp, sp, -512
686; RV64ZICBOP-NEXT:    prefetch.r 0(sp)
687; RV64ZICBOP-NEXT:    addi sp, sp, 512
688; RV64ZICBOP-NEXT:    ret
689;
690; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_0:
691; RV64ZICBOPZIHINTNTL:       # %bb.0:
692; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
693; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
694; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(sp)
695; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
696; RV64ZICBOPZIHINTNTL-NEXT:    ret
697  %data = alloca [128 x i32], align 4
698  %base = bitcast ptr %data to ptr
699  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 0
700  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
701  ret void
702}
703
704define void @test_prefetch_frameindex_1() nounwind {
705; RV32I-LABEL: test_prefetch_frameindex_1:
706; RV32I:       # %bb.0:
707; RV32I-NEXT:    lui a0, 1
708; RV32I-NEXT:    addi a0, a0, 16
709; RV32I-NEXT:    sub sp, sp, a0
710; RV32I-NEXT:    lui a0, 1
711; RV32I-NEXT:    addi a0, a0, 16
712; RV32I-NEXT:    add sp, sp, a0
713; RV32I-NEXT:    ret
714;
715; RV64I-LABEL: test_prefetch_frameindex_1:
716; RV64I:       # %bb.0:
717; RV64I-NEXT:    lui a0, 1
718; RV64I-NEXT:    addiw a0, a0, 16
719; RV64I-NEXT:    sub sp, sp, a0
720; RV64I-NEXT:    lui a0, 1
721; RV64I-NEXT:    addiw a0, a0, 16
722; RV64I-NEXT:    add sp, sp, a0
723; RV64I-NEXT:    ret
724;
725; RV32ZICBOP-LABEL: test_prefetch_frameindex_1:
726; RV32ZICBOP:       # %bb.0:
727; RV32ZICBOP-NEXT:    lui a0, 1
728; RV32ZICBOP-NEXT:    addi a0, a0, 16
729; RV32ZICBOP-NEXT:    sub sp, sp, a0
730; RV32ZICBOP-NEXT:    addi a0, sp, 16
731; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
732; RV32ZICBOP-NEXT:    lui a0, 1
733; RV32ZICBOP-NEXT:    addi a0, a0, 16
734; RV32ZICBOP-NEXT:    add sp, sp, a0
735; RV32ZICBOP-NEXT:    ret
736;
737; RV64ZICBOP-LABEL: test_prefetch_frameindex_1:
738; RV64ZICBOP:       # %bb.0:
739; RV64ZICBOP-NEXT:    lui a0, 1
740; RV64ZICBOP-NEXT:    addiw a0, a0, 16
741; RV64ZICBOP-NEXT:    sub sp, sp, a0
742; RV64ZICBOP-NEXT:    addi a0, sp, 16
743; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
744; RV64ZICBOP-NEXT:    lui a0, 1
745; RV64ZICBOP-NEXT:    addiw a0, a0, 16
746; RV64ZICBOP-NEXT:    add sp, sp, a0
747; RV64ZICBOP-NEXT:    ret
748;
749; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_1:
750; RV64ZICBOPZIHINTNTL:       # %bb.0:
751; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, 1
752; RV64ZICBOPZIHINTNTL-NEXT:    addiw a0, a0, 16
753; RV64ZICBOPZIHINTNTL-NEXT:    sub sp, sp, a0
754; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, sp, 16
755; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
756; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
757; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, 1
758; RV64ZICBOPZIHINTNTL-NEXT:    addiw a0, a0, 16
759; RV64ZICBOPZIHINTNTL-NEXT:    add sp, sp, a0
760; RV64ZICBOPZIHINTNTL-NEXT:    ret
761  %data = alloca [1024 x i32], align 4
762  %ptr = bitcast ptr %data to ptr
763  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
764  ret void
765}
766
767define void @test_prefetch_frameindex_2() nounwind {
768; RV32I-LABEL: test_prefetch_frameindex_2:
769; RV32I:       # %bb.0:
770; RV32I-NEXT:    addi sp, sp, -512
771; RV32I-NEXT:    addi sp, sp, 512
772; RV32I-NEXT:    ret
773;
774; RV64I-LABEL: test_prefetch_frameindex_2:
775; RV64I:       # %bb.0:
776; RV64I-NEXT:    addi sp, sp, -512
777; RV64I-NEXT:    addi sp, sp, 512
778; RV64I-NEXT:    ret
779;
780; RV32ZICBOP-LABEL: test_prefetch_frameindex_2:
781; RV32ZICBOP:       # %bb.0:
782; RV32ZICBOP-NEXT:    addi sp, sp, -512
783; RV32ZICBOP-NEXT:    addi a0, sp, 16
784; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
785; RV32ZICBOP-NEXT:    addi sp, sp, 512
786; RV32ZICBOP-NEXT:    ret
787;
788; RV64ZICBOP-LABEL: test_prefetch_frameindex_2:
789; RV64ZICBOP:       # %bb.0:
790; RV64ZICBOP-NEXT:    addi sp, sp, -512
791; RV64ZICBOP-NEXT:    addi a0, sp, 16
792; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
793; RV64ZICBOP-NEXT:    addi sp, sp, 512
794; RV64ZICBOP-NEXT:    ret
795;
796; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_2:
797; RV64ZICBOPZIHINTNTL:       # %bb.0:
798; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
799; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, sp, 16
800; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
801; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
802; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
803; RV64ZICBOPZIHINTNTL-NEXT:    ret
804  %data = alloca [128 x i32], align 4
805  %base = bitcast ptr %data to ptr
806  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 4
807  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
808  ret void
809}
810
811define void @test_prefetch_frameindex_3() nounwind {
812; RV32I-LABEL: test_prefetch_frameindex_3:
813; RV32I:       # %bb.0:
814; RV32I-NEXT:    addi sp, sp, -512
815; RV32I-NEXT:    addi sp, sp, 512
816; RV32I-NEXT:    ret
817;
818; RV64I-LABEL: test_prefetch_frameindex_3:
819; RV64I:       # %bb.0:
820; RV64I-NEXT:    addi sp, sp, -512
821; RV64I-NEXT:    addi sp, sp, 512
822; RV64I-NEXT:    ret
823;
824; RV32ZICBOP-LABEL: test_prefetch_frameindex_3:
825; RV32ZICBOP:       # %bb.0:
826; RV32ZICBOP-NEXT:    addi sp, sp, -512
827; RV32ZICBOP-NEXT:    addi a0, sp, -16
828; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
829; RV32ZICBOP-NEXT:    addi sp, sp, 512
830; RV32ZICBOP-NEXT:    ret
831;
832; RV64ZICBOP-LABEL: test_prefetch_frameindex_3:
833; RV64ZICBOP:       # %bb.0:
834; RV64ZICBOP-NEXT:    addi sp, sp, -512
835; RV64ZICBOP-NEXT:    addi a0, sp, -16
836; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
837; RV64ZICBOP-NEXT:    addi sp, sp, 512
838; RV64ZICBOP-NEXT:    ret
839;
840; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_3:
841; RV64ZICBOPZIHINTNTL:       # %bb.0:
842; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
843; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, sp, -16
844; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
845; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
846; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
847; RV64ZICBOPZIHINTNTL-NEXT:    ret
848  %data = alloca [128 x i32], align 4
849  %base = bitcast ptr %data to ptr
850  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 -4
851  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
852  ret void
853}
854
855define void @test_prefetch_frameindex_4() nounwind {
856; RV32I-LABEL: test_prefetch_frameindex_4:
857; RV32I:       # %bb.0:
858; RV32I-NEXT:    addi sp, sp, -512
859; RV32I-NEXT:    addi sp, sp, 512
860; RV32I-NEXT:    ret
861;
862; RV64I-LABEL: test_prefetch_frameindex_4:
863; RV64I:       # %bb.0:
864; RV64I-NEXT:    addi sp, sp, -512
865; RV64I-NEXT:    addi sp, sp, 512
866; RV64I-NEXT:    ret
867;
868; RV32ZICBOP-LABEL: test_prefetch_frameindex_4:
869; RV32ZICBOP:       # %bb.0:
870; RV32ZICBOP-NEXT:    addi sp, sp, -512
871; RV32ZICBOP-NEXT:    prefetch.r 32(sp)
872; RV32ZICBOP-NEXT:    addi sp, sp, 512
873; RV32ZICBOP-NEXT:    ret
874;
875; RV64ZICBOP-LABEL: test_prefetch_frameindex_4:
876; RV64ZICBOP:       # %bb.0:
877; RV64ZICBOP-NEXT:    addi sp, sp, -512
878; RV64ZICBOP-NEXT:    prefetch.r 32(sp)
879; RV64ZICBOP-NEXT:    addi sp, sp, 512
880; RV64ZICBOP-NEXT:    ret
881;
882; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_4:
883; RV64ZICBOPZIHINTNTL:       # %bb.0:
884; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
885; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
886; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 32(sp)
887; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
888; RV64ZICBOPZIHINTNTL-NEXT:    ret
889  %data = alloca [128 x i32], align 4
890  %base = bitcast ptr %data to ptr
891  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 8
892  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
893  ret void
894}
895
896define void @test_prefetch_frameindex_5() nounwind {
897; RV32I-LABEL: test_prefetch_frameindex_5:
898; RV32I:       # %bb.0:
899; RV32I-NEXT:    addi sp, sp, -512
900; RV32I-NEXT:    addi sp, sp, 512
901; RV32I-NEXT:    ret
902;
903; RV64I-LABEL: test_prefetch_frameindex_5:
904; RV64I:       # %bb.0:
905; RV64I-NEXT:    addi sp, sp, -512
906; RV64I-NEXT:    addi sp, sp, 512
907; RV64I-NEXT:    ret
908;
909; RV32ZICBOP-LABEL: test_prefetch_frameindex_5:
910; RV32ZICBOP:       # %bb.0:
911; RV32ZICBOP-NEXT:    addi sp, sp, -512
912; RV32ZICBOP-NEXT:    prefetch.r -32(sp)
913; RV32ZICBOP-NEXT:    addi sp, sp, 512
914; RV32ZICBOP-NEXT:    ret
915;
916; RV64ZICBOP-LABEL: test_prefetch_frameindex_5:
917; RV64ZICBOP:       # %bb.0:
918; RV64ZICBOP-NEXT:    addi sp, sp, -512
919; RV64ZICBOP-NEXT:    prefetch.r -32(sp)
920; RV64ZICBOP-NEXT:    addi sp, sp, 512
921; RV64ZICBOP-NEXT:    ret
922;
923; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_5:
924; RV64ZICBOPZIHINTNTL:       # %bb.0:
925; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
926; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
927; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -32(sp)
928; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
929; RV64ZICBOPZIHINTNTL-NEXT:    ret
930  %data = alloca [128 x i32], align 4
931  %base = bitcast ptr %data to ptr
932  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 -8
933  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
934  ret void
935}
936
937define void @test_prefetch_frameindex_6() nounwind {
938; RV32I-LABEL: test_prefetch_frameindex_6:
939; RV32I:       # %bb.0:
940; RV32I-NEXT:    addi sp, sp, -512
941; RV32I-NEXT:    addi sp, sp, 512
942; RV32I-NEXT:    ret
943;
944; RV64I-LABEL: test_prefetch_frameindex_6:
945; RV64I:       # %bb.0:
946; RV64I-NEXT:    addi sp, sp, -512
947; RV64I-NEXT:    addi sp, sp, 512
948; RV64I-NEXT:    ret
949;
950; RV32ZICBOP-LABEL: test_prefetch_frameindex_6:
951; RV32ZICBOP:       # %bb.0:
952; RV32ZICBOP-NEXT:    addi sp, sp, -512
953; RV32ZICBOP-NEXT:    prefetch.r 2016(sp)
954; RV32ZICBOP-NEXT:    addi sp, sp, 512
955; RV32ZICBOP-NEXT:    ret
956;
957; RV64ZICBOP-LABEL: test_prefetch_frameindex_6:
958; RV64ZICBOP:       # %bb.0:
959; RV64ZICBOP-NEXT:    addi sp, sp, -512
960; RV64ZICBOP-NEXT:    prefetch.r 2016(sp)
961; RV64ZICBOP-NEXT:    addi sp, sp, 512
962; RV64ZICBOP-NEXT:    ret
963;
964; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_6:
965; RV64ZICBOPZIHINTNTL:       # %bb.0:
966; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
967; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
968; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 2016(sp)
969; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
970; RV64ZICBOPZIHINTNTL-NEXT:    ret
971  %data = alloca [128 x i32], align 4
972  %base = bitcast ptr %data to ptr
973  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 504
974  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
975  ret void
976}
977
978define void @test_prefetch_frameindex_7() nounwind {
979; RV32I-LABEL: test_prefetch_frameindex_7:
980; RV32I:       # %bb.0:
981; RV32I-NEXT:    addi sp, sp, -512
982; RV32I-NEXT:    addi sp, sp, 512
983; RV32I-NEXT:    ret
984;
985; RV64I-LABEL: test_prefetch_frameindex_7:
986; RV64I:       # %bb.0:
987; RV64I-NEXT:    addi sp, sp, -512
988; RV64I-NEXT:    addi sp, sp, 512
989; RV64I-NEXT:    ret
990;
991; RV32ZICBOP-LABEL: test_prefetch_frameindex_7:
992; RV32ZICBOP:       # %bb.0:
993; RV32ZICBOP-NEXT:    addi sp, sp, -512
994; RV32ZICBOP-NEXT:    prefetch.r -2048(sp)
995; RV32ZICBOP-NEXT:    addi sp, sp, 512
996; RV32ZICBOP-NEXT:    ret
997;
998; RV64ZICBOP-LABEL: test_prefetch_frameindex_7:
999; RV64ZICBOP:       # %bb.0:
1000; RV64ZICBOP-NEXT:    addi sp, sp, -512
1001; RV64ZICBOP-NEXT:    prefetch.r -2048(sp)
1002; RV64ZICBOP-NEXT:    addi sp, sp, 512
1003; RV64ZICBOP-NEXT:    ret
1004;
1005; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_7:
1006; RV64ZICBOPZIHINTNTL:       # %bb.0:
1007; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
1008; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1009; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -2048(sp)
1010; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
1011; RV64ZICBOPZIHINTNTL-NEXT:    ret
1012  %data = alloca [128 x i32], align 4
1013  %base = bitcast ptr %data to ptr
1014  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 -512
1015  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1016  ret void
1017}
1018
1019define void @test_prefetch_frameindex_8() nounwind {
1020; RV32I-LABEL: test_prefetch_frameindex_8:
1021; RV32I:       # %bb.0:
1022; RV32I-NEXT:    addi sp, sp, -512
1023; RV32I-NEXT:    addi sp, sp, 512
1024; RV32I-NEXT:    ret
1025;
1026; RV64I-LABEL: test_prefetch_frameindex_8:
1027; RV64I:       # %bb.0:
1028; RV64I-NEXT:    addi sp, sp, -512
1029; RV64I-NEXT:    addi sp, sp, 512
1030; RV64I-NEXT:    ret
1031;
1032; RV32ZICBOP-LABEL: test_prefetch_frameindex_8:
1033; RV32ZICBOP:       # %bb.0:
1034; RV32ZICBOP-NEXT:    addi sp, sp, -512
1035; RV32ZICBOP-NEXT:    addi a0, sp, 2020
1036; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
1037; RV32ZICBOP-NEXT:    addi sp, sp, 512
1038; RV32ZICBOP-NEXT:    ret
1039;
1040; RV64ZICBOP-LABEL: test_prefetch_frameindex_8:
1041; RV64ZICBOP:       # %bb.0:
1042; RV64ZICBOP-NEXT:    addi sp, sp, -512
1043; RV64ZICBOP-NEXT:    addi a0, sp, 2020
1044; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
1045; RV64ZICBOP-NEXT:    addi sp, sp, 512
1046; RV64ZICBOP-NEXT:    ret
1047;
1048; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_8:
1049; RV64ZICBOPZIHINTNTL:       # %bb.0:
1050; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
1051; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, sp, 2020
1052; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1053; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
1054; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
1055; RV64ZICBOPZIHINTNTL-NEXT:    ret
1056  %data = alloca [128 x i32], align 4
1057  %base = bitcast ptr %data to ptr
1058  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 505
1059  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1060  ret void
1061}
1062
1063define void @test_prefetch_frameindex_9() nounwind {
1064; RV32I-LABEL: test_prefetch_frameindex_9:
1065; RV32I:       # %bb.0:
1066; RV32I-NEXT:    addi sp, sp, -512
1067; RV32I-NEXT:    addi sp, sp, 512
1068; RV32I-NEXT:    ret
1069;
1070; RV64I-LABEL: test_prefetch_frameindex_9:
1071; RV64I:       # %bb.0:
1072; RV64I-NEXT:    addi sp, sp, -512
1073; RV64I-NEXT:    addi sp, sp, 512
1074; RV64I-NEXT:    ret
1075;
1076; RV32ZICBOP-LABEL: test_prefetch_frameindex_9:
1077; RV32ZICBOP:       # %bb.0:
1078; RV32ZICBOP-NEXT:    addi sp, sp, -512
1079; RV32ZICBOP-NEXT:    mv a0, sp
1080; RV32ZICBOP-NEXT:    addi a0, a0, -4
1081; RV32ZICBOP-NEXT:    prefetch.r -2048(a0)
1082; RV32ZICBOP-NEXT:    addi sp, sp, 512
1083; RV32ZICBOP-NEXT:    ret
1084;
1085; RV64ZICBOP-LABEL: test_prefetch_frameindex_9:
1086; RV64ZICBOP:       # %bb.0:
1087; RV64ZICBOP-NEXT:    addi sp, sp, -512
1088; RV64ZICBOP-NEXT:    mv a0, sp
1089; RV64ZICBOP-NEXT:    addi a0, a0, -4
1090; RV64ZICBOP-NEXT:    prefetch.r -2048(a0)
1091; RV64ZICBOP-NEXT:    addi sp, sp, 512
1092; RV64ZICBOP-NEXT:    ret
1093;
1094; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_frameindex_9:
1095; RV64ZICBOPZIHINTNTL:       # %bb.0:
1096; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, -512
1097; RV64ZICBOPZIHINTNTL-NEXT:    mv a0, sp
1098; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, -4
1099; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1100; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -2048(a0)
1101; RV64ZICBOPZIHINTNTL-NEXT:    addi sp, sp, 512
1102; RV64ZICBOPZIHINTNTL-NEXT:    ret
1103  %data = alloca [128 x i32], align 4
1104  %base = bitcast ptr %data to ptr
1105  %ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 -513
1106  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1107  ret void
1108}
1109
1110define void @test_prefetch_constant_address_0() nounwind {
1111; RV32I-LABEL: test_prefetch_constant_address_0:
1112; RV32I:       # %bb.0:
1113; RV32I-NEXT:    ret
1114;
1115; RV64I-LABEL: test_prefetch_constant_address_0:
1116; RV64I:       # %bb.0:
1117; RV64I-NEXT:    ret
1118;
1119; RV32ZICBOP-LABEL: test_prefetch_constant_address_0:
1120; RV32ZICBOP:       # %bb.0:
1121; RV32ZICBOP-NEXT:    lui a0, 1
1122; RV32ZICBOP-NEXT:    prefetch.r 32(a0)
1123; RV32ZICBOP-NEXT:    ret
1124;
1125; RV64ZICBOP-LABEL: test_prefetch_constant_address_0:
1126; RV64ZICBOP:       # %bb.0:
1127; RV64ZICBOP-NEXT:    lui a0, 1
1128; RV64ZICBOP-NEXT:    prefetch.r 32(a0)
1129; RV64ZICBOP-NEXT:    ret
1130;
1131; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_constant_address_0:
1132; RV64ZICBOPZIHINTNTL:       # %bb.0:
1133; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, 1
1134; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1135; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 32(a0)
1136; RV64ZICBOPZIHINTNTL-NEXT:    ret
1137  %ptr = inttoptr i64 4128 to ptr
1138  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1139  ret void
1140}
1141
1142define void @test_prefetch_constant_address_1() nounwind {
1143; RV32I-LABEL: test_prefetch_constant_address_1:
1144; RV32I:       # %bb.0:
1145; RV32I-NEXT:    ret
1146;
1147; RV64I-LABEL: test_prefetch_constant_address_1:
1148; RV64I:       # %bb.0:
1149; RV64I-NEXT:    ret
1150;
1151; RV32ZICBOP-LABEL: test_prefetch_constant_address_1:
1152; RV32ZICBOP:       # %bb.0:
1153; RV32ZICBOP-NEXT:    lui a0, 1
1154; RV32ZICBOP-NEXT:    addi a0, a0, 31
1155; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
1156; RV32ZICBOP-NEXT:    ret
1157;
1158; RV64ZICBOP-LABEL: test_prefetch_constant_address_1:
1159; RV64ZICBOP:       # %bb.0:
1160; RV64ZICBOP-NEXT:    lui a0, 1
1161; RV64ZICBOP-NEXT:    addiw a0, a0, 31
1162; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
1163; RV64ZICBOP-NEXT:    ret
1164;
1165; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_constant_address_1:
1166; RV64ZICBOPZIHINTNTL:       # %bb.0:
1167; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, 1
1168; RV64ZICBOPZIHINTNTL-NEXT:    addiw a0, a0, 31
1169; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1170; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
1171; RV64ZICBOPZIHINTNTL-NEXT:    ret
1172  %ptr = inttoptr i64 4127 to ptr
1173  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1174  ret void
1175}
1176
1177define void @test_prefetch_constant_address_2() nounwind {
1178; RV32I-LABEL: test_prefetch_constant_address_2:
1179; RV32I:       # %bb.0:
1180; RV32I-NEXT:    ret
1181;
1182; RV64I-LABEL: test_prefetch_constant_address_2:
1183; RV64I:       # %bb.0:
1184; RV64I-NEXT:    ret
1185;
1186; RV32ZICBOP-LABEL: test_prefetch_constant_address_2:
1187; RV32ZICBOP:       # %bb.0:
1188; RV32ZICBOP-NEXT:    lui a0, 1048561
1189; RV32ZICBOP-NEXT:    prefetch.r 32(a0)
1190; RV32ZICBOP-NEXT:    ret
1191;
1192; RV64ZICBOP-LABEL: test_prefetch_constant_address_2:
1193; RV64ZICBOP:       # %bb.0:
1194; RV64ZICBOP-NEXT:    lui a0, 1048561
1195; RV64ZICBOP-NEXT:    prefetch.r 32(a0)
1196; RV64ZICBOP-NEXT:    ret
1197;
1198; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_constant_address_2:
1199; RV64ZICBOPZIHINTNTL:       # %bb.0:
1200; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, 1048561
1201; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1202; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 32(a0)
1203; RV64ZICBOPZIHINTNTL-NEXT:    ret
1204  %ptr = inttoptr i64 18446744073709490208 to ptr
1205  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1206  ret void
1207}
1208
1209define void @test_prefetch_constant_address_3() nounwind {
1210; RV32I-LABEL: test_prefetch_constant_address_3:
1211; RV32I:       # %bb.0:
1212; RV32I-NEXT:    ret
1213;
1214; RV64I-LABEL: test_prefetch_constant_address_3:
1215; RV64I:       # %bb.0:
1216; RV64I-NEXT:    ret
1217;
1218; RV32ZICBOP-LABEL: test_prefetch_constant_address_3:
1219; RV32ZICBOP:       # %bb.0:
1220; RV32ZICBOP-NEXT:    lui a0, 1048561
1221; RV32ZICBOP-NEXT:    addi a0, a0, 31
1222; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
1223; RV32ZICBOP-NEXT:    ret
1224;
1225; RV64ZICBOP-LABEL: test_prefetch_constant_address_3:
1226; RV64ZICBOP:       # %bb.0:
1227; RV64ZICBOP-NEXT:    lui a0, 1048561
1228; RV64ZICBOP-NEXT:    addiw a0, a0, 31
1229; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
1230; RV64ZICBOP-NEXT:    ret
1231;
1232; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_constant_address_3:
1233; RV64ZICBOPZIHINTNTL:       # %bb.0:
1234; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, 1048561
1235; RV64ZICBOPZIHINTNTL-NEXT:    addiw a0, a0, 31
1236; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1237; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
1238; RV64ZICBOPZIHINTNTL-NEXT:    ret
1239  %ptr = inttoptr i64 18446744073709490207 to ptr
1240  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1241  ret void
1242}
1243
1244@g = external global [1024 x i32], align 4
1245
1246define void @test_prefetch_global_0() nounwind {
1247; RV32I-LABEL: test_prefetch_global_0:
1248; RV32I:       # %bb.0:
1249; RV32I-NEXT:    ret
1250;
1251; RV64I-LABEL: test_prefetch_global_0:
1252; RV64I:       # %bb.0:
1253; RV64I-NEXT:    ret
1254;
1255; RV32ZICBOP-LABEL: test_prefetch_global_0:
1256; RV32ZICBOP:       # %bb.0:
1257; RV32ZICBOP-NEXT:    lui a0, %hi(g)
1258; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g)
1259; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
1260; RV32ZICBOP-NEXT:    ret
1261;
1262; RV64ZICBOP-LABEL: test_prefetch_global_0:
1263; RV64ZICBOP:       # %bb.0:
1264; RV64ZICBOP-NEXT:    lui a0, %hi(g)
1265; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g)
1266; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
1267; RV64ZICBOP-NEXT:    ret
1268;
1269; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_0:
1270; RV64ZICBOPZIHINTNTL:       # %bb.0:
1271; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g)
1272; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g)
1273; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1274; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
1275; RV64ZICBOPZIHINTNTL-NEXT:    ret
1276  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 0
1277  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1278  ret void
1279}
1280
1281define void @test_prefetch_global_1() nounwind {
1282; RV32I-LABEL: test_prefetch_global_1:
1283; RV32I:       # %bb.0:
1284; RV32I-NEXT:    ret
1285;
1286; RV64I-LABEL: test_prefetch_global_1:
1287; RV64I:       # %bb.0:
1288; RV64I-NEXT:    ret
1289;
1290; RV32ZICBOP-LABEL: test_prefetch_global_1:
1291; RV32ZICBOP:       # %bb.0:
1292; RV32ZICBOP-NEXT:    lui a0, %hi(g+16)
1293; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g+16)
1294; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
1295; RV32ZICBOP-NEXT:    ret
1296;
1297; RV64ZICBOP-LABEL: test_prefetch_global_1:
1298; RV64ZICBOP:       # %bb.0:
1299; RV64ZICBOP-NEXT:    lui a0, %hi(g+16)
1300; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g+16)
1301; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
1302; RV64ZICBOP-NEXT:    ret
1303;
1304; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_1:
1305; RV64ZICBOPZIHINTNTL:       # %bb.0:
1306; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g+16)
1307; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g+16)
1308; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1309; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
1310; RV64ZICBOPZIHINTNTL-NEXT:    ret
1311  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 4
1312  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1313  ret void
1314}
1315
1316define void @test_prefetch_global_2() nounwind {
1317; RV32I-LABEL: test_prefetch_global_2:
1318; RV32I:       # %bb.0:
1319; RV32I-NEXT:    ret
1320;
1321; RV64I-LABEL: test_prefetch_global_2:
1322; RV64I:       # %bb.0:
1323; RV64I-NEXT:    ret
1324;
1325; RV32ZICBOP-LABEL: test_prefetch_global_2:
1326; RV32ZICBOP:       # %bb.0:
1327; RV32ZICBOP-NEXT:    lui a0, %hi(g-16)
1328; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g-16)
1329; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
1330; RV32ZICBOP-NEXT:    ret
1331;
1332; RV64ZICBOP-LABEL: test_prefetch_global_2:
1333; RV64ZICBOP:       # %bb.0:
1334; RV64ZICBOP-NEXT:    lui a0, %hi(g-16)
1335; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g-16)
1336; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
1337; RV64ZICBOP-NEXT:    ret
1338;
1339; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_2:
1340; RV64ZICBOPZIHINTNTL:       # %bb.0:
1341; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g-16)
1342; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g-16)
1343; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1344; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
1345; RV64ZICBOPZIHINTNTL-NEXT:    ret
1346  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 -4
1347  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1348  ret void
1349}
1350
1351define void @test_prefetch_global_3() nounwind {
1352; RV32I-LABEL: test_prefetch_global_3:
1353; RV32I:       # %bb.0:
1354; RV32I-NEXT:    ret
1355;
1356; RV64I-LABEL: test_prefetch_global_3:
1357; RV64I:       # %bb.0:
1358; RV64I-NEXT:    ret
1359;
1360; RV32ZICBOP-LABEL: test_prefetch_global_3:
1361; RV32ZICBOP:       # %bb.0:
1362; RV32ZICBOP-NEXT:    lui a0, %hi(g)
1363; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g)
1364; RV32ZICBOP-NEXT:    prefetch.r 32(a0)
1365; RV32ZICBOP-NEXT:    ret
1366;
1367; RV64ZICBOP-LABEL: test_prefetch_global_3:
1368; RV64ZICBOP:       # %bb.0:
1369; RV64ZICBOP-NEXT:    lui a0, %hi(g)
1370; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g)
1371; RV64ZICBOP-NEXT:    prefetch.r 32(a0)
1372; RV64ZICBOP-NEXT:    ret
1373;
1374; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_3:
1375; RV64ZICBOPZIHINTNTL:       # %bb.0:
1376; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g)
1377; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g)
1378; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1379; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 32(a0)
1380; RV64ZICBOPZIHINTNTL-NEXT:    ret
1381  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 8
1382  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1383  ret void
1384}
1385
1386define void @test_prefetch_global_4() nounwind {
1387; RV32I-LABEL: test_prefetch_global_4:
1388; RV32I:       # %bb.0:
1389; RV32I-NEXT:    ret
1390;
1391; RV64I-LABEL: test_prefetch_global_4:
1392; RV64I:       # %bb.0:
1393; RV64I-NEXT:    ret
1394;
1395; RV32ZICBOP-LABEL: test_prefetch_global_4:
1396; RV32ZICBOP:       # %bb.0:
1397; RV32ZICBOP-NEXT:    lui a0, %hi(g)
1398; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g)
1399; RV32ZICBOP-NEXT:    prefetch.r -32(a0)
1400; RV32ZICBOP-NEXT:    ret
1401;
1402; RV64ZICBOP-LABEL: test_prefetch_global_4:
1403; RV64ZICBOP:       # %bb.0:
1404; RV64ZICBOP-NEXT:    lui a0, %hi(g)
1405; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g)
1406; RV64ZICBOP-NEXT:    prefetch.r -32(a0)
1407; RV64ZICBOP-NEXT:    ret
1408;
1409; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_4:
1410; RV64ZICBOPZIHINTNTL:       # %bb.0:
1411; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g)
1412; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g)
1413; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1414; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -32(a0)
1415; RV64ZICBOPZIHINTNTL-NEXT:    ret
1416  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 -8
1417  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1418  ret void
1419}
1420
1421define void @test_prefetch_global_5() nounwind {
1422; RV32I-LABEL: test_prefetch_global_5:
1423; RV32I:       # %bb.0:
1424; RV32I-NEXT:    ret
1425;
1426; RV64I-LABEL: test_prefetch_global_5:
1427; RV64I:       # %bb.0:
1428; RV64I-NEXT:    ret
1429;
1430; RV32ZICBOP-LABEL: test_prefetch_global_5:
1431; RV32ZICBOP:       # %bb.0:
1432; RV32ZICBOP-NEXT:    lui a0, %hi(g)
1433; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g)
1434; RV32ZICBOP-NEXT:    prefetch.r 2016(a0)
1435; RV32ZICBOP-NEXT:    ret
1436;
1437; RV64ZICBOP-LABEL: test_prefetch_global_5:
1438; RV64ZICBOP:       # %bb.0:
1439; RV64ZICBOP-NEXT:    lui a0, %hi(g)
1440; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g)
1441; RV64ZICBOP-NEXT:    prefetch.r 2016(a0)
1442; RV64ZICBOP-NEXT:    ret
1443;
1444; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_5:
1445; RV64ZICBOPZIHINTNTL:       # %bb.0:
1446; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g)
1447; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g)
1448; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1449; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 2016(a0)
1450; RV64ZICBOPZIHINTNTL-NEXT:    ret
1451  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 504
1452  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1453  ret void
1454}
1455
1456define void @test_prefetch_global_6() nounwind {
1457; RV32I-LABEL: test_prefetch_global_6:
1458; RV32I:       # %bb.0:
1459; RV32I-NEXT:    ret
1460;
1461; RV64I-LABEL: test_prefetch_global_6:
1462; RV64I:       # %bb.0:
1463; RV64I-NEXT:    ret
1464;
1465; RV32ZICBOP-LABEL: test_prefetch_global_6:
1466; RV32ZICBOP:       # %bb.0:
1467; RV32ZICBOP-NEXT:    lui a0, %hi(g)
1468; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g)
1469; RV32ZICBOP-NEXT:    prefetch.r -2048(a0)
1470; RV32ZICBOP-NEXT:    ret
1471;
1472; RV64ZICBOP-LABEL: test_prefetch_global_6:
1473; RV64ZICBOP:       # %bb.0:
1474; RV64ZICBOP-NEXT:    lui a0, %hi(g)
1475; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g)
1476; RV64ZICBOP-NEXT:    prefetch.r -2048(a0)
1477; RV64ZICBOP-NEXT:    ret
1478;
1479; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_6:
1480; RV64ZICBOPZIHINTNTL:       # %bb.0:
1481; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g)
1482; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g)
1483; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1484; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -2048(a0)
1485; RV64ZICBOPZIHINTNTL-NEXT:    ret
1486  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 -512
1487  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1488  ret void
1489}
1490
1491define void @test_prefetch_global_7() nounwind {
1492; RV32I-LABEL: test_prefetch_global_7:
1493; RV32I:       # %bb.0:
1494; RV32I-NEXT:    ret
1495;
1496; RV64I-LABEL: test_prefetch_global_7:
1497; RV64I:       # %bb.0:
1498; RV64I-NEXT:    ret
1499;
1500; RV32ZICBOP-LABEL: test_prefetch_global_7:
1501; RV32ZICBOP:       # %bb.0:
1502; RV32ZICBOP-NEXT:    lui a0, %hi(g+2020)
1503; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g+2020)
1504; RV32ZICBOP-NEXT:    prefetch.r 0(a0)
1505; RV32ZICBOP-NEXT:    ret
1506;
1507; RV64ZICBOP-LABEL: test_prefetch_global_7:
1508; RV64ZICBOP:       # %bb.0:
1509; RV64ZICBOP-NEXT:    lui a0, %hi(g+2020)
1510; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g+2020)
1511; RV64ZICBOP-NEXT:    prefetch.r 0(a0)
1512; RV64ZICBOP-NEXT:    ret
1513;
1514; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_7:
1515; RV64ZICBOPZIHINTNTL:       # %bb.0:
1516; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g+2020)
1517; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g+2020)
1518; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1519; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r 0(a0)
1520; RV64ZICBOPZIHINTNTL-NEXT:    ret
1521  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 505
1522  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1523  ret void
1524}
1525
1526define void @test_prefetch_global_8() nounwind {
1527; RV32I-LABEL: test_prefetch_global_8:
1528; RV32I:       # %bb.0:
1529; RV32I-NEXT:    ret
1530;
1531; RV64I-LABEL: test_prefetch_global_8:
1532; RV64I:       # %bb.0:
1533; RV64I-NEXT:    ret
1534;
1535; RV32ZICBOP-LABEL: test_prefetch_global_8:
1536; RV32ZICBOP:       # %bb.0:
1537; RV32ZICBOP-NEXT:    lui a0, %hi(g-4)
1538; RV32ZICBOP-NEXT:    addi a0, a0, %lo(g-4)
1539; RV32ZICBOP-NEXT:    prefetch.r -2048(a0)
1540; RV32ZICBOP-NEXT:    ret
1541;
1542; RV64ZICBOP-LABEL: test_prefetch_global_8:
1543; RV64ZICBOP:       # %bb.0:
1544; RV64ZICBOP-NEXT:    lui a0, %hi(g-4)
1545; RV64ZICBOP-NEXT:    addi a0, a0, %lo(g-4)
1546; RV64ZICBOP-NEXT:    prefetch.r -2048(a0)
1547; RV64ZICBOP-NEXT:    ret
1548;
1549; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_global_8:
1550; RV64ZICBOPZIHINTNTL:       # %bb.0:
1551; RV64ZICBOPZIHINTNTL-NEXT:    lui a0, %hi(g-4)
1552; RV64ZICBOPZIHINTNTL-NEXT:    addi a0, a0, %lo(g-4)
1553; RV64ZICBOPZIHINTNTL-NEXT:    ntl.all
1554; RV64ZICBOPZIHINTNTL-NEXT:    prefetch.r -2048(a0)
1555; RV64ZICBOPZIHINTNTL-NEXT:    ret
1556  %ptr = getelementptr [1024 x i32], ptr @g, i32 0, i32 -513
1557  call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
1558  ret void
1559}
1560