[llvm] [SPIRV] Implement bare bones lowering for G_PREFETCH (PR #215505)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 06:42:27 PDT 2026
================
@@ -1467,6 +1471,37 @@ bool SPIRVInstructionSelector::selectDebugTrap(Register ResVReg,
return true;
}
+bool SPIRVInstructionSelector::selectPrefetch(Register ResVReg,
+ SPIRVTypeInst ResType,
+ MachineInstr &I) const {
+ // llvm.prefetch is missing info about how many bytes to prefetch that
+ // OpUntypedPrefetchKHR instruction requires, so just drop the instruction
+ // in case untyped pointers are enabled since OCL prefetch cannot take
+ // untyped pointers.
----------------
MrSidims wrote:
> but can't we simply obtain the number of bytes of the element to be prefetched
We can't. IR is untyped, so 1 x sizeof(unknown_ptr_base) is unknown.
Technically, https://github.com/llvm/llvm-project/pull/201233 doesn't prevent `spv.assign.type/spv.assign.ptr.type` intrinsics generation, so we could reuse them as `SPIRVEmitIntrinsics` goes before `SPIRVInstructionSelector`. But while currently it's possible to query ptr.type even when SPV_KHR_untyped_pointers extension enabled - I don't have a strong opinion, where it should be considered as 'fine' or as 'a buf of #201233'.
https://github.com/llvm/llvm-project/pull/215505
More information about the llvm-commits
mailing list