[clang] [Matrix][HLSL] Fix transpose matrix layout bugs (PR #202486)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 9 13:47:40 PDT 2026


================
@@ -106,20 +106,57 @@ export float2x2 mat_mat_cm_rm(column_major float2x3 a, row_major float3x2 b) { r
 // CHECK: [[T:%.*]] = call {{.*}} <6 x float> @llvm.matrix.transpose.v6f32(<6 x float> [[BMat]], i32 2, i32 3)
 // CHECK: call {{.*}} <4 x float> @llvm.matrix.multiply.v4f32.v6f32.v6f32(<6 x float> [[AMat]], <6 x float> [[T]], i32 2, i32 3, i32 2)
 
-// -----------------------------------------------------------------------------
-// __builtin_hlsl_transpose: row-major operand swaps Rows/Cols passed to the
-// underlying intrinsic.
-// -----------------------------------------------------------------------------
+// Column-major return: result transform tracks the TU default, not the keyword.
+export column_major float2x2 mat_mat_dst_cm(column_major float2x3 a, column_major float3x2 b) { return mul(a, b); }
+// CHECK-LABEL: define {{.*}} <4 x float> @_Z14mat_mat_dst_cm
+// CHECK: [[MUL:%.*]] = call {{.*}} <4 x float> @llvm.matrix.multiply.v4f32.v6f32.v6f32(<6 x float> %{{.*}}, <6 x float> %{{.*}}, i32 2, i32 3, i32 2)
+// CHECK-NOT: @llvm.matrix.transpose
+
+// Row-major return: same result as above; the keyword does not force a transform.
----------------
hekota wrote:

The comment does not match the expected code which includes a `transpose`.

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


More information about the cfe-commits mailing list