[llvm] [SPIRV] Implement bare bones lowering for G_PREFETCH (PR #215505)

Marcos Maronas via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 06:15:46 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.
----------------
maarquitos14 wrote:

If I read the OpenCL spec correctly (see below quote), OCL needs the number of bytes (or a proxy) too, doesn't it?

> void prefetch(const __global gentype *p, size_t num_gentypes)

> Prefetch num_gentypes * sizeof(gentype) bytes into the global cache. The prefetch instruction is applied to a work-item in a work-group and does not affect the functional behavior of the kernel.

https://github.com/llvm/llvm-project/pull/215505


More information about the llvm-commits mailing list