Repository: microsoft/DirectXShaderCompiler (2026-04-03T20:59:40Z)

Issue:
[SM6.10] linAlgMatrixMultiplyAccumulate DXIL mismatch
**Description**
Compile linAlgMatrixMultiplyAccumulate , we get this DXIL:
%8 = call %dx.types.LinAlgMatrixC8M16N32U2S1 @dx.op.linAlgMatrixMultiplyAccumulate.mC8M16N32U2S1.mC8M16N32U2S1.mC8M16N16U0S1.mC8M16N32U1S1(i32 -2147483637, %dx.types.LinAlgMatrixC8M16N32U2S1 undef, %dx.types.LinAlgMatrixC8M16N16U0S1 %7, %dx.types.LinAlgMatrixC8M16N32U1S1 %5) ; LinAlgMatrixMultiplyAccumulate(matrixA,matrixB,matrixC)

the input order is C, A and B, it doesn't match spec's A, B and C.

**Steps to Reproduce**
<!--- Provide a description of how to reproduce the error. If possible please 
provide source and tool command line options. If the issue reproduces on
Compiler Explorer (https://godbolt.org/) or Shader Playground
(https://shader-playground.timjones.io/) please provide a link. If the source is
split across multiple files, please preprocess into a single file using DXC's 
command line `-P -Fi <path>`. --->


**Actual Behavior**
<!--- Please provide error output or a description of the observed issue. --->

**Environment**
- DXC version: release-preview-1.10.2605
- Host Operating System <!--- Host operating system and version --->



Discussion:
Ah this looks like an ordering issue in the header! 

https://github.com/microsoft/DirectXShaderCompiler/blob/main/tools/clang/lib/Headers/hlsl/dx/linalg.h#L377

this should be 

```c++
__builtin_LinAlg_MatrixMatrixMultiplyAccumulate(
        __handle, MatrixA.__handle, MatrixB.__handle, __handle);
```

instead. We'll get this fixed ASAP! Thanks for the report!



Patch:
diff --git a/tools/clang/lib/Headers/hlsl/dx/linalg.h b/tools/clang/lib/Headers/hlsl/dx/linalg.h
index 2a636662cd..3c45e39683 100644
--- a/tools/clang/lib/Headers/hlsl/dx/linalg.h
+++ b/tools/clang/lib/Headers/hlsl/dx/linalg.h
@@ -373,8 +373,8 @@ class Matrix {
                            void>::type
   MultiplyAccumulate(const Matrix<LHSTy, M, K, MatrixUse::A, Scope> MatrixA,
                      const Matrix<RHSTy, K, N, MatrixUse::B, Scope> MatrixB) {
-    __builtin_LinAlg_MatrixMatrixMultiplyAccumulate(
-        __handle, __handle, MatrixA.__handle, MatrixB.__handle);
+    __builtin_LinAlg_MatrixMatrixMultiplyAccumulate(__handle, MatrixA.__handle,
+                                                    MatrixB.__handle, __handle);
   }
 };
 


Test patch:
diff --git a/tools/clang/test/CodeGenDXIL/hlsl/linalg/api/matrix-class.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/linalg/api/matrix-class.hlsl
index 575a367273..8d1f43f4b2 100644
--- a/tools/clang/test/CodeGenDXIL/hlsl/linalg/api/matrix-class.hlsl
+++ b/tools/clang/test/CodeGenDXIL/hlsl/linalg/api/matrix-class.hlsl
@@ -157,10 +157,10 @@ void main(uint ID : SV_GroupID)
 // Matrix::MultiplyAccumulate
 //
 // CHECK: %[[ACCUM4:.*]] = call %dx.types.LinAlgMatrixC9M4N4U2S1
-// CHECK-SAME: @dx.op.linAlgMatrixMultiplyAccumulate.mC9M4N4U2S1.mC9M4N4U2S1.mC9M4N4U0S1.mC9M4N4U1S1(i32 -2147483637,
-// CHECK-SAME: %dx.types.LinAlgMatrixC9M4N4U2S1 %[[ACCUM3]],
+// CHECK-SAME: @dx.op.linAlgMatrixMultiplyAccumulate.mC9M4N4U2S1.mC9M4N4U0S1.mC9M4N4U1S1.mC9M4N4U2S1(i32 -2147483637,
 // CHECK-SAME: %dx.types.LinAlgMatrixC9M4N4U0S1 %[[MATA1]],
-// CHECK-SAME: %dx.types.LinAlgMatrixC9M4N4U1S1 %[[MATB1_2]])
+// CHECK-SAME: %dx.types.LinAlgMatrixC9M4N4U1S1 %[[MATB1_2]],
+// CHECK-SAME: %dx.types.LinAlgMatrixC9M4N4U2S1 %[[ACCUM3]])
 // CHECK-SAME: ; LinAlgMatrixMultiplyAccumulate(matrixA,matrixB,matrixC)
   AccMat2.MultiplyAccumulate(MatA1, MatB1);