[clang] [HLSL] Add matrix support for degrees(), radians() (PR #218573)

Kaitlin Peng via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 00:47:14 PDT 2026


================
@@ -0,0 +1,195 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s \
+// RUN:   -fnative-half-type -fnative-int16-type -emit-llvm -o - \
+// RUN:   | FileCheck %s --check-prefixes=CHECK,NATIVE_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -o - \
+// RUN:   | FileCheck %s --check-prefixes=CHECK,NO_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-library %s \
+// RUN:   -fnative-half-type -fnative-int16-type -emit-llvm -o - \
+// RUN:   | FileCheck %s --check-prefixes=CHECK,NATIVE_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-library %s -emit-llvm -o - \
+// RUN:   | FileCheck %s --check-prefixes=CHECK,NO_HALF
----------------
kmpeng wrote:

(Same for `radians_mat.hlsl`)
We should only need the DXIL `-fnative-half-type` run line here, like `degrees.hlsl`. The SPIRV runs have identical codegen to DXIL since the `degrees` implementation was moved entirely into the header. `NO_HALF` runs are usually there to check for `.f16` vs `.f32` calls, but that difference doesn't exist anymore for the same reason. Running without `-fnative-half-type` here just promotes `half` -> `float` and emits the same `fmul` the float tests already cover.

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


More information about the cfe-commits mailing list