[llvm] [SPIR-V] Access-chain aggregate pointers to element 0 for cooperative matrix load/store (PR #202050)

Dmitry Sidorov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 06:52:34 PDT 2026


================
@@ -3023,6 +3025,20 @@ bool SPIRVModuleAnalysis::runOnModule(Module &M) {
   collectReqs(M, MAI, MMI, *ST);
   collectDeclarations(M);
 
+  // CooperativeMatrixKHR in a Shader module mandates the Vulkan memory model
+  // (spirv-val rejects Shader + CooperativeMatrixKHR under GLSL450). Now that
+  // requirements are collected, derive the model from the capability rather
+  // than a default, unless one was set explicitly via !spirv.MemoryModel
+  // metadata.
+  if (ST->isShader() && MAI.Mem == SPIRV::MemoryModel::GLSL450 &&
+      !M.getNamedMetadata("spirv.MemoryModel") &&
+      MAI.Reqs.isCapabilityRequired(SPIRV::Capability::CooperativeMatrixKHR)) {
+    MAI.Mem = SPIRV::MemoryModel::VulkanKHR;
+    MAI.Reqs.getAndAddRequirements(SPIRV::OperandCategory::MemoryModelOperand,
+                                   MAI.Mem, *ST);
+    MAI.Reqs.addExtension(SPIRV::Extension::SPV_KHR_vulkan_memory_model);
+  }
----------------
MrSidims wrote:

Yeah, I believe it's a separate bug you are fixing, right?

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


More information about the llvm-commits mailing list