[clang] [HLSL] Add matrix support for float->float pure function intrinsics (PR #202455)

Kaitlin Peng via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 25 17:52:10 PDT 2026


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

nit?: these matrix tests all use 4 RUN lines (both backends + both half modes), but I don't think it's necessary for most of them. Most are target independent and generate identical IR for dxil/spirv, so the spirv runs here are basically pure duplicates. The scalar versions of these tests (e.g. `acos.hlsl`) mostly use 2 run lines (dxil + native_half, dxil OR spirv + no_half), which sufficently covers what we need for these intrinsics. I think the exceptions to this are `saturate`/`frac`/`rsqrt`, which lower to `@llvm.dx.*` vs. `@llvm.spv.*`, so those probably should have all 4.

I won't block on this, but something to think about.

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


More information about the cfe-commits mailing list