[clang] [HLSL][Matrix] introduce MatrixElementExpr as accessor and swizzle operator (PR #171225)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 17 23:40:33 PST 2025
================
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl \
+// RUN: -ast-print -disable-llvm-passes -o - -hlsl-entry main %s \
+// RUN: | FileCheck %s
+
+typedef float float4x4 __attribute__((matrix_type(4,4)));
+typedef float float2 __attribute__((ext_vector_type(2)));
+typedef float float3 __attribute__((ext_vector_type(3)));
+
+float4x4 gMat;
+
+[numthreads(1, 1, 1)]
+void main() {
+ float4x4 A = gMat;
+ float3 v1 = A._11_22_33;
+ float2 v2 = A._m00_m11;
----------------
hekota wrote:
```suggestion
float3 v1 = A._12_21_32;
float2 v2 = A._m01_m10;
```
Using different indices tests that column and row do not get accidentally mixed up.
https://github.com/llvm/llvm-project/pull/171225
More information about the cfe-commits
mailing list