Skip to content

[SPIR-V] llc fails to lower G_PREFETCH #214265

Description

@MrSidims

short reproducer

mrsidims@mrsidims:~/LLVM-work/build$ cat test.ll

define spir_kernel void @foo(ptr addrspace(1) %p) {
  call void @llvm.prefetch.p1(ptr addrspace(1) %p, i32 0, i32 3, i32 1)
  ret void
}
mrsidims@mrsidims:~/LLVM-work/build$ ./bin/llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown test.ll
LLVM ERROR: unable to legalize instruction: G_PREFETCH %0:pid(p1), 0, 3, 1 :: (load unknown-size from %ir.p, align 1, addrspace 1) (in function: foo)

it's a subject of discussion what to target during lowering, possible candidates:
for OpenCL
no extension: OCL prefetch
SPV_KHR_untyped_pointers extension enabled (this is the best match IMHO): OpUntypedPrefetchKHR (the instruction is being added in #201233 , but there is no bridge between the SPIR-V instruction and llvm.prefetch.
SPV_KHR_untyped_pointers disabled, but SPV_INTEL_cache_controls enabled: combination of OCL prefetch and some decorations from the extension

Vulkan:
I don't know much about it, but OpUntypedPrefetchKHR would just work

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions