[llvm] [SPIRV][Matrix] Legalize store of matrix to array of vector memory layout (PR #188139)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 12:48:16 PDT 2026


================
@@ -2280,6 +2280,12 @@ void SPIRVGlobalRegistry::addStructOffsetDecorations(
 void SPIRVGlobalRegistry::addArrayStrideDecorations(
     Register Reg, Type *ElementType, MachineIRBuilder &MIRBuilder) {
   uint32_t SizeInBytes = DataLayout().getTypeSizeInBits(ElementType) / 8;
+  // Vulkan requires vec3 to have the same alignment as vec4
----------------
s-perron wrote:

Vulkan does not require this all of the time. There is a vulkan extension to allow the scalar block layout: https://docs.vulkan.org/refpages/latest/refpages/source/VK_EXT_scalar_block_layout.html.

For HLSL, we expect scalar block layout to be enabled if the users uses the DX layout, which will be the default in clang. 

The way I see this working is that the backend, which has no idea what alignments will be allows, uses the alignemnt, size, and stride that are implicit in the llvm-ir, and does nothing special. If a FE wants different alignment then the need to make it explicit in the llvm-ir.

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


More information about the llvm-commits mailing list