================
@@ -1228,6 +1229,38 @@ static bool generateExtInst(const SPIRV::IncomingCall 
*Call,
                  : SPIRV::OpenCLExtInst::fmax;
   }
 
+  // ExtInst prefetch cannot take an untyped pointer, so emit
+  // OpUntypedPrefetchKHR with Num Bytes = num elements * element byte size.
+  if (Number == SPIRV::OpenCLExtInst::prefetch && Call->Arguments.size() >= 2) 
{
+    Register PtrReg = Call->Arguments[0];
+    SPIRVTypeInst PtrTy = GR->getSPIRVTypeForVReg(PtrReg);
+    if (PtrTy && PtrTy->getOpcode() == SPIRV::OpTypeUntypedPointerKHR) {
+      MachineRegisterInfo *MRI = MIRBuilder.getMRI();
+      Register NumElems = Call->Arguments[1];
+      SPIRVTypeInst SizeTy = GR->getSPIRVTypeForVReg(NumElems);
+      unsigned ElemBytes = GR->getDeducedPointeeByteSize(CB.getArgOperand(0));
+      Register NumBytes = NumElems;
+      if (ElemBytes > 1 && SizeTy) {
----------------
MrSidims wrote:

added comment covering both the 1 and 0 cases above if (ElemBytes > 1)

https://github.com/llvm/llvm-project/pull/201233
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to