[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:09 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
+
+// CHECK-LABEL: test_acos_float1x2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
+// CHECK: ret <2 x float>
+float1x2 test_acos_float1x2(float1x2 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float1x3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
+// CHECK: ret <3 x float>
+float1x3 test_acos_float1x3(float1x3 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float1x4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
+// CHECK: ret <4 x float>
+float1x4 test_acos_float1x4(float1x4 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float2x1
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
+// CHECK: ret <2 x float>
+float2x1 test_acos_float2x1(float2x1 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float2x2
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
+// CHECK: ret <4 x float>
+float2x2 test_acos_float2x2(float2x2 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float2x3
+// CHECK: call reassoc nnan ninf nsz arcp afn <6 x float> @llvm.acos.v6f32
+// CHECK: ret <6 x float>
+float2x3 test_acos_float2x3(float2x3 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float2x4
+// CHECK: call reassoc nnan ninf nsz arcp afn <8 x float> @llvm.acos.v8f32
+// CHECK: ret <8 x float>
+float2x4 test_acos_float2x4(float2x4 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float3x1
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
+// CHECK: ret <3 x float>
+float3x1 test_acos_float3x1(float3x1 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float3x2
+// CHECK: call reassoc nnan ninf nsz arcp afn <6 x float> @llvm.acos.v6f32
+// CHECK: ret <6 x float>
+float3x2 test_acos_float3x2(float3x2 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float3x3
+// CHECK: call reassoc nnan ninf nsz arcp afn <9 x float> @llvm.acos.v9f32
+// CHECK: ret <9 x float>
+float3x3 test_acos_float3x3(float3x3 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float3x4
+// CHECK: call reassoc nnan ninf nsz arcp afn <12 x float> @llvm.acos.v12f32
+// CHECK: ret <12 x float>
+float3x4 test_acos_float3x4(float3x4 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float4x1
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
+// CHECK: ret <4 x float>
+float4x1 test_acos_float4x1(float4x1 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float4x2
+// CHECK: call reassoc nnan ninf nsz arcp afn <8 x float> @llvm.acos.v8f32
+// CHECK: ret <8 x float>
+float4x2 test_acos_float4x2(float4x2 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float4x3
+// CHECK: call reassoc nnan ninf nsz arcp afn <12 x float> @llvm.acos.v12f32
+// CHECK: ret <12 x float>
+float4x3 test_acos_float4x3(float4x3 p0) { return acos(p0); }
+
+// CHECK-LABEL: test_acos_float4x4
+// CHECK: call reassoc nnan ninf nsz arcp afn <16 x float> @llvm.acos.v16f32
+// CHECK: ret <16 x float>
+float4x4 test_acos_float4x4(float4x4 p0) { return acos(p0); }
+
+
+// CHECK-LABEL: test_acos_half1x2
+// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <2 x half> @llvm.acos.v2f16
+// NO_HALF: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
+// CHECK: ret <2 x {{half|float}}>
----------------
kmpeng wrote:
nit: the way you check returns is inconsistent across all these files. Some do it like this while others have separate check lines. Pretty sure most of the scalar versions don't check return lines at all.
I personally am not a fan of having `half|float` in a shared check but it's defensible.
https://github.com/llvm/llvm-project/pull/202455
More information about the cfe-commits
mailing list