Files
clang-p2996/llvm/test/CodeGen/RISCV/prefetch.ll
Piyou Chen 7ce4e933ea [RISCV] Implement prefetch locality by NTLH
We add the MemOperand then backend will generate NTLH automatically.

```
__builtin_prefetch(ptr,  0 /* rw==read */, 0 /* locality */); => ntl.all + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 1 /* locality */); => ntl.pall + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 2 /* locality */); => ntl.p1 + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 3 /* locality */); => prefetch.r (ptr)
```

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D154691
2023-07-16 20:32:46 -07:00

348 lines
10 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefix=RV32I %s
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefix=RV64I %s
; RUN: llc -mtriple=riscv32 -mattr=+zicbop -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefix=RV32ZICBOP %s
; RUN: llc -mtriple=riscv64 -mattr=zicbop -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefix=RV64ZICBOP %s
; RUN: llc -mtriple=riscv64 -mattr=+zicbop,+experimental-zihintntl -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefix=RV64ZICBOPZIHINTNTL %s
declare void @llvm.prefetch(ptr, i32, i32, i32)
define void @test_prefetch_read_locality_0(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_read_locality_0:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_read_locality_0:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_read_locality_0:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.r 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_read_locality_0:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.r 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_0:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.all
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.r 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 0, i32 1)
ret void
}
define void @test_prefetch_write_locality_0(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_write_locality_0:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_write_locality_0:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_write_locality_0:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.w 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_write_locality_0:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.w 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_0:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.all
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.w 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 1, i32 0, i32 1)
ret void
}
define void @test_prefetch_instruction_locality_0(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_instruction_locality_0:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_instruction_locality_0:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_0:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.i 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_0:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.i 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_0:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.all
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.i 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 0, i32 0)
ret void
}
define void @test_prefetch_read_locality_1(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_read_locality_1:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_read_locality_1:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_read_locality_1:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.r 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_read_locality_1:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.r 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_1:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.pall
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.r 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 1, i32 1)
ret void
}
define void @test_prefetch_write_locality_1(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_write_locality_1:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_write_locality_1:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_write_locality_1:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.w 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_write_locality_1:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.w 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_1:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.pall
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.w 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 1, i32 1, i32 1)
ret void
}
define void @test_prefetch_instruction_locality_1(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_instruction_locality_1:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_instruction_locality_1:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_1:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.i 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_1:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.i 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_1:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.pall
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.i 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 1, i32 0)
ret void
}
define void @test_prefetch_read_locality_2(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_read_locality_2:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_read_locality_2:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_read_locality_2:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.r 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_read_locality_2:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.r 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_2:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.p1
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.r 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 2, i32 1)
ret void
}
define void @test_prefetch_write_locality_2(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_write_locality_2:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_write_locality_2:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_write_locality_2:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.w 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_write_locality_2:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.w 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_2:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.p1
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.w 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 1, i32 2, i32 1)
ret void
}
define void @test_prefetch_instruction_locality_2(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_instruction_locality_2:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_instruction_locality_2:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_2:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.i 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_2:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.i 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_2:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: ntl.p1
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.i 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 2, i32 0)
ret void
}
define void @test_prefetch_read_locality_3(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_read_locality_3:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_read_locality_3:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_read_locality_3:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.r 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_read_locality_3:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.r 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_read_locality_3:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.r 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 3, i32 1)
ret void
}
define void @test_prefetch_write_locality_3(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_write_locality_3:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_write_locality_3:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_write_locality_3:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.w 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_write_locality_3:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.w 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_write_locality_3:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.w 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 1, i32 3, i32 1)
ret void
}
define void @test_prefetch_instruction_locality_3(ptr %a) nounwind {
; RV32I-LABEL: test_prefetch_instruction_locality_3:
; RV32I: # %bb.0:
; RV32I-NEXT: ret
;
; RV64I-LABEL: test_prefetch_instruction_locality_3:
; RV64I: # %bb.0:
; RV64I-NEXT: ret
;
; RV32ZICBOP-LABEL: test_prefetch_instruction_locality_3:
; RV32ZICBOP: # %bb.0:
; RV32ZICBOP-NEXT: prefetch.i 0(a0)
; RV32ZICBOP-NEXT: ret
;
; RV64ZICBOP-LABEL: test_prefetch_instruction_locality_3:
; RV64ZICBOP: # %bb.0:
; RV64ZICBOP-NEXT: prefetch.i 0(a0)
; RV64ZICBOP-NEXT: ret
;
; RV64ZICBOPZIHINTNTL-LABEL: test_prefetch_instruction_locality_3:
; RV64ZICBOPZIHINTNTL: # %bb.0:
; RV64ZICBOPZIHINTNTL-NEXT: prefetch.i 0(a0)
; RV64ZICBOPZIHINTNTL-NEXT: ret
call void @llvm.prefetch(ptr %a, i32 0, i32 3, i32 0)
ret void
}