[clang] Hlsl dst function (PR #133828)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 4 11:50:52 PDT 2025
https://github.com/metkarpoonam updated https://github.com/llvm/llvm-project/pull/133828
>From 3a45246453d120da108e597d23da0fb8d9df0b1b Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Mon, 31 Mar 2025 16:49:18 -0700
Subject: [PATCH 1/9] Implement a dst function with test cases for HLSL codegen
and sema
---
.../lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 6 +++
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 25 ++++++++++
clang/test/CodeGenHLSL/builtins/dst.hlsl | 48 +++++++++++++++++++
clang/test/SemaHLSL/BuiltIns/dst-error.hlsl | 37 ++++++++++++++
4 files changed, 116 insertions(+)
create mode 100644 clang/test/CodeGenHLSL/builtins/dst.hlsl
create mode 100644 clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 8cdd63d7e07bb..5ea8faf169380 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -35,6 +35,12 @@ length_vec_impl(vector<T, N> X) {
#endif
}
+template <typename T>
+constexpr vector<T, 4> dst_impl(vector<T, 4> src0, vector<T, 4> src1) {
+ vector<T, 4> dest = {1, src0[1] * src1[1], src0[2], src1[3]};
+ return dest;
+}
+
template <typename T> constexpr T distance_impl(T X, T Y) {
return length_impl(X - Y);
}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index fd799b8d874ae..7ae94731234f9 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -174,6 +174,31 @@ const inline float distance(__detail::HLSL_FIXED_VECTOR<float, N> X,
__detail::HLSL_FIXED_VECTOR<float, N> Y) {
return __detail::distance_vec_impl(X, Y);
}
+//===----------------------------------------------------------------------===//
+// dst builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn fvector dst( fvector, fvector)
+/// \brief Returns the length of a vector
+/// \param src0 [in] The first vector contain {_, d*d, d*d, _}
+/// \param src1 [in] The second vector contain {_, 1/d, _, 1/d}
+///
+/// Return the computed distance vector contain {1, d, d*d, 1/d}
+
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+const inline vector<half, 4> dst(vector<half, 4> src0, vector<half, 4> src1) {
+ return __detail::dst_impl(src0, src1);
+}
+
+const inline vector<float, 4> dst(vector<float, 4> src0,
+ vector<float, 4> src1) {
+ return __detail::dst_impl(src0, src1);
+}
+
+const inline vector<double, 4> dst(vector<double, 4> src0,
+ vector<double, 4> src1) {
+ return __detail::dst_impl(src0, src1);
+}
//===----------------------------------------------------------------------===//
// fmod builtins
diff --git a/clang/test/CodeGenHLSL/builtins/dst.hlsl b/clang/test/CodeGenHLSL/builtins/dst.hlsl
new file mode 100644
index 0000000000000..c62c9be5b0c1d
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/dst.hlsl
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
+
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z12dstWithFloatDv4_fS_(
+// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <4 x float> [[P]], i64 1
+// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q]], i64 1
+// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[VECEXT]]
+// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
+// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x float> [[VECINIT]], <4 x float> [[P]], <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
+// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x float> [[VECINIT3]], <4 x float> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
+// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
+
+float4 dstWithFloat(float4 p1, float4 p2)
+{
+ return dst(p1, p2);
+}
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x half> @_Z11dstwithHalfDv4_DhS_(
+// CHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[P:%.*]], <4 x half> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <4 x half> [[P]], i64 1
+// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x half> [[Q]], i64 1
+// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[VECEXT1]], [[VECEXT]]
+// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half poison>, half [[MULRES]], i64 1
+// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x half> [[VECINIT]], <4 x half> [[P]], <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
+// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x half> [[VECINIT3]], <4 x half> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
+// CHECK-NEXT: ret <4 x half> [[VECINIT5]]
+half4 dstwithHalf(half4 p1, half4 p2)
+{
+ return dst(p1, p2);
+}
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> @_Z13dstWithDoubleDv4_dS_(
+// CHECK-SAME: <4 x double> noundef nofpclass(nan inf) [[P:%.*]], <4 x double> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <4 x double> [[P]], i64 1
+// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x double> [[Q]], i64 1
+// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn double [[VECEXT1]], [[VECEXT]]
+// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x double> <double 1.000000e+00, double poison, double poison, double poison>, double [[MULRES]], i64 1
+// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x double> [[VECINIT]], <4 x double> [[P]], <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
+// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x double> [[VECINIT3]], <4 x double> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
+// CHECK-NEXT: ret <4 x double> [[VECINIT5]]
+double4 dstWithDouble(double4 p1, double4 p2)
+{
+ return dst(p1, p2);
+}
diff --git a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
new file mode 100644
index 0000000000000..0680ebf6fc3d7
--- /dev/null
+++ b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify
+
+float4 test_too_many_arg(float4 p0)
+{
+ dst(p0, p0, p0);
+ // expected-error at -1 {{no matching function for call to 'dst'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+}
+
+float4 test_no_second_arg(float4 p0)
+{
+ return dst(p0);
+ // expected-error at -1 {{no matching function for call to 'dst'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 1 was provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 1 was provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 1 was provided}}
+}
+
+float4 test_no_args()
+{
+ return dst();
+ // expected-error at -1 {{no matching function for call to 'dst'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+}
+
+float4 test_3_components(float3 p0, float3 p1)
+{
+ return dst(p0, p1);
+ // expected-error at -1 {{no matching function for call to 'dst'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<[...], 3>' to 'vector<[...], 4>' for 1st argument}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<float, 3>' to 'vector<half, 4>' for 1st argument}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<float, 3>' to 'vector<double, 4>' for 1st argument}}
+}
\ No newline at end of file
>From 4cde5a56ab7ea8e188160ad6d727f44c3209e52a Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Mon, 31 Mar 2025 16:56:54 -0700
Subject: [PATCH 2/9] Add newline in dst-error.hlsl
---
clang/test/SemaHLSL/BuiltIns/dst-error.hlsl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
index 0680ebf6fc3d7..6bff46ffc223b 100644
--- a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
@@ -34,4 +34,4 @@ float4 test_3_components(float3 p0, float3 p1)
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<[...], 3>' to 'vector<[...], 4>' for 1st argument}}
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<float, 3>' to 'vector<half, 4>' for 1st argument}}
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<float, 3>' to 'vector<double, 4>' for 1st argument}}
-}
\ No newline at end of file
+}
>From 0b82759537649907eb7b7449d4802953151910d5 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Tue, 1 Apr 2025 11:42:46 -0700
Subject: [PATCH 3/9] Small change in dst.hlsl
---
clang/test/CodeGenHLSL/builtins/dst.hlsl | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/clang/test/CodeGenHLSL/builtins/dst.hlsl b/clang/test/CodeGenHLSL/builtins/dst.hlsl
index c62c9be5b0c1d..0b88df83c1fa9 100644
--- a/clang/test/CodeGenHLSL/builtins/dst.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dst.hlsl
@@ -3,8 +3,7 @@
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z12dstWithFloatDv4_fS_(
// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
-// CHECK-NEXT: entry:
-// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <4 x float> [[P]], i64 1
+// CHECK: [[VECEXT:%.*]] = extractelement <4 x float> [[P]], i64 1
// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q]], i64 1
// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[VECEXT]]
// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
@@ -19,8 +18,7 @@ float4 dstWithFloat(float4 p1, float4 p2)
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x half> @_Z11dstwithHalfDv4_DhS_(
// CHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[P:%.*]], <4 x half> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
-// CHECK-NEXT: entry:
-// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <4 x half> [[P]], i64 1
+// CHECK: [[VECEXT:%.*]] = extractelement <4 x half> [[P]], i64 1
// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x half> [[Q]], i64 1
// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[VECEXT1]], [[VECEXT]]
// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half poison>, half [[MULRES]], i64 1
@@ -34,8 +32,7 @@ half4 dstwithHalf(half4 p1, half4 p2)
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> @_Z13dstWithDoubleDv4_dS_(
// CHECK-SAME: <4 x double> noundef nofpclass(nan inf) [[P:%.*]], <4 x double> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
-// CHECK-NEXT: entry:
-// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <4 x double> [[P]], i64 1
+// CHECK: [[VECEXT:%.*]] = extractelement <4 x double> [[P]], i64 1
// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x double> [[Q]], i64 1
// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn double [[VECEXT1]], [[VECEXT]]
// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x double> <double 1.000000e+00, double poison, double poison, double poison>, double [[MULRES]], i64 1
>From 464aee13001b77915b9368ca64c163befb799372 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Tue, 1 Apr 2025 23:20:12 -0700
Subject: [PATCH 4/9] Add test case with shrink return type, scalar inputs, as
well as test case with arg1 as float and arg2 as float4
---
clang/test/CodeGenHLSL/builtins/dst.hlsl | 42 +++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/clang/test/CodeGenHLSL/builtins/dst.hlsl b/clang/test/CodeGenHLSL/builtins/dst.hlsl
index 0b88df83c1fa9..21b8c81770d60 100644
--- a/clang/test/CodeGenHLSL/builtins/dst.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dst.hlsl
@@ -31,7 +31,7 @@ half4 dstwithHalf(half4 p1, half4 p2)
}
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> @_Z13dstWithDoubleDv4_dS_(
-// CHECK-SAME: <4 x double> noundef nofpclass(nan inf) [[P:%.*]], <4 x double> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-SAME: <4 x double> noundef nofpclass(nan inf) [[P:%.*]], <4 x double> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
// CHECK: [[VECEXT:%.*]] = extractelement <4 x double> [[P]], i64 1
// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x double> [[Q]], i64 1
// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn double [[VECEXT1]], [[VECEXT]]
@@ -43,3 +43,43 @@ double4 dstWithDouble(double4 p1, double4 p2)
{
return dst(p1, p2);
}
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z9testfloatff(
+// CHECK-SAME: float noundef nofpclass(nan inf) [[P:%.*]], float noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[Q]], [[P]]
+// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
+// CHECK-NEXT: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float [[P]], i64 2
+// CHECK-NEXT: [[VECINIT5:%.*]] = insertelement <4 x float> [[VECINIT3]], float [[Q]], i64 3
+// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
+float4 testfloat(float a, float b)
+{
+ return dst(a, b);
+}
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z10testfloat4fDv4_f(
+// CHECK-SAME: float noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q:%.*]], i64 1
+// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[P]]
+// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
+// CHECK-NEXT: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float %a, i64 2
+// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x float> [[VECINIT3]], <4 x float> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
+// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
+float4 testfloat4(float a, float4 b)
+{
+ return dst(a, b);
+}
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x half> @_Z21testRetTypeShriinkingDv4_fS_(
+// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK: [[VECEXT:%.*]] = extractelement <4 x float> [[P]], i64 1
+// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q]], i64 1
+// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[VECEXT]]
+// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
+// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x float> [[VECINIT]], <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
+// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x float> %vecinit3.i, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
+// CHECK-NEXT: [[CONV:%.*]] = fptrunc reassoc nnan ninf nsz arcp afn <4 x float> [[VECINIT5]] to <4 x half>
+// CHECK-NEXT: ret <4 x half> [[CONV]]
+half4 testRetTypeShriinking(float4 a, float4 b)
+{
+ return dst(a, b);
+}
\ No newline at end of file
>From cd53a270c159deb91e231a56c33db6e2c4d1a758 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Wed, 2 Apr 2025 14:24:41 -0700
Subject: [PATCH 5/9] Address review comments
---
clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 6 +++---
clang/test/SemaHLSL/BuiltIns/dst-error.hlsl | 14 ++++++++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 5ea8faf169380..6e8575054bc93 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -36,9 +36,9 @@ length_vec_impl(vector<T, N> X) {
}
template <typename T>
-constexpr vector<T, 4> dst_impl(vector<T, 4> src0, vector<T, 4> src1) {
- vector<T, 4> dest = {1, src0[1] * src1[1], src0[2], src1[3]};
- return dest;
+constexpr vector<T, 4> dst_impl(vector<T, 4> Src0, vector<T, 4> Src1) {
+ vector<T, 4> Dest = {1, Src0[1] * Src1[1], Src0[2], Src1[3]};
+ return Dest;
}
template <typename T> constexpr T distance_impl(T X, T Y) {
diff --git a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
index 6bff46ffc223b..9f65dfe28d8ff 100644
--- a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
@@ -35,3 +35,17 @@ float4 test_3_components(float3 p0, float3 p1)
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<float, 3>' to 'vector<half, 4>' for 1st argument}}
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<float, 3>' to 'vector<double, 4>' for 1st argument}}
}
+
+float4 test_float2(double4 p0, float4 p1)
+{
+ return dst(p0, p1);
+ // expected-error at -1 {{call to 'dst' is ambiguous}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function}}
+}
+
+float2 test_float2(float4 p0, float4 p1)
+{
+ return dst(p0, p1);
+ // expected-warning at -1 {{implicit conversion truncates vector: 'vector<float, 4>' (vector of 4 'float' values) to 'vector<float, 2>' (vector of 2 'float' values)}}
+}
\ No newline at end of file
>From bd44eaa531ea9366a79c4d36e29b9cdfcc5e0e8e Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Wed, 2 Apr 2025 14:32:00 -0700
Subject: [PATCH 6/9] Add new line in dst.hlsl and dst-error.hlsl
---
clang/test/CodeGenHLSL/builtins/dst.hlsl | 2 +-
clang/test/SemaHLSL/BuiltIns/dst-error.hlsl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/CodeGenHLSL/builtins/dst.hlsl b/clang/test/CodeGenHLSL/builtins/dst.hlsl
index 21b8c81770d60..a7abebe1e2d8d 100644
--- a/clang/test/CodeGenHLSL/builtins/dst.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dst.hlsl
@@ -82,4 +82,4 @@ float4 testfloat4(float a, float4 b)
half4 testRetTypeShriinking(float4 a, float4 b)
{
return dst(a, b);
-}
\ No newline at end of file
+}
diff --git a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
index 9f65dfe28d8ff..f242fc3eb5cd0 100644
--- a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
@@ -48,4 +48,4 @@ float2 test_float2(float4 p0, float4 p1)
{
return dst(p0, p1);
// expected-warning at -1 {{implicit conversion truncates vector: 'vector<float, 4>' (vector of 4 'float' values) to 'vector<float, 2>' (vector of 2 'float' values)}}
-}
\ No newline at end of file
+}
>From b31595bc70b904a0b80b3b1d68ae13dfde826f55 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Wed, 2 Apr 2025 15:37:51 -0700
Subject: [PATCH 7/9] Give descriptive names to the test cases in
dst-error.hlsl and remove the test from dst.hlsl
---
clang/test/CodeGenHLSL/builtins/dst.hlsl | 25 +++++----------------
clang/test/SemaHLSL/BuiltIns/dst-error.hlsl | 4 ++--
2 files changed, 7 insertions(+), 22 deletions(-)
diff --git a/clang/test/CodeGenHLSL/builtins/dst.hlsl b/clang/test/CodeGenHLSL/builtins/dst.hlsl
index a7abebe1e2d8d..9e63b9ae22096 100644
--- a/clang/test/CodeGenHLSL/builtins/dst.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dst.hlsl
@@ -44,19 +44,19 @@ double4 dstWithDouble(double4 p1, double4 p2)
return dst(p1, p2);
}
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z9testfloatff(
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z16dstWithScalarInpff(
// CHECK-SAME: float noundef nofpclass(nan inf) [[P:%.*]], float noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
// CHECK: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[Q]], [[P]]
// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
// CHECK-NEXT: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float [[P]], i64 2
// CHECK-NEXT: [[VECINIT5:%.*]] = insertelement <4 x float> [[VECINIT3]], float [[Q]], i64 3
// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
-float4 testfloat(float a, float b)
+float4 dstWithScalarInp(float a, float b)
{
return dst(a, b);
}
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z10testfloat4fDv4_f(
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z22dstWithScalarAndVectorfDv4_f(
// CHECK-SAME: float noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
// CHECK: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q:%.*]], i64 1
// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[P]]
@@ -64,22 +64,7 @@ float4 testfloat(float a, float b)
// CHECK-NEXT: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float %a, i64 2
// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x float> [[VECINIT3]], <4 x float> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
-float4 testfloat4(float a, float4 b)
+float4 dstWithScalarAndVector(float a, float4 b)
{
return dst(a, b);
-}
-
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x half> @_Z21testRetTypeShriinkingDv4_fS_(
-// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
-// CHECK: [[VECEXT:%.*]] = extractelement <4 x float> [[P]], i64 1
-// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q]], i64 1
-// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[VECEXT]]
-// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
-// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x float> [[VECINIT]], <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
-// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x float> %vecinit3.i, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
-// CHECK-NEXT: [[CONV:%.*]] = fptrunc reassoc nnan ninf nsz arcp afn <4 x float> [[VECINIT5]] to <4 x half>
-// CHECK-NEXT: ret <4 x half> [[CONV]]
-half4 testRetTypeShriinking(float4 a, float4 b)
-{
- return dst(a, b);
-}
+}
\ No newline at end of file
diff --git a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
index f242fc3eb5cd0..f728320112b9d 100644
--- a/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/dst-error.hlsl
@@ -36,7 +36,7 @@ float4 test_3_components(float3 p0, float3 p1)
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<float, 3>' to 'vector<double, 4>' for 1st argument}}
}
-float4 test_float2(double4 p0, float4 p1)
+float4 test_with_ambiguous_inp(double4 p0, float4 p1)
{
return dst(p0, p1);
// expected-error at -1 {{call to 'dst' is ambiguous}}
@@ -44,7 +44,7 @@ float4 test_float2(double4 p0, float4 p1)
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function}}
}
-float2 test_float2(float4 p0, float4 p1)
+float2 test_with_return_float2(float4 p0, float4 p1)
{
return dst(p0, p1);
// expected-warning at -1 {{implicit conversion truncates vector: 'vector<float, 4>' (vector of 4 'float' values) to 'vector<float, 2>' (vector of 2 'float' values)}}
>From 5b4157ab3176d266abc6b996e8c057efc2c39039 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Wed, 2 Apr 2025 15:43:28 -0700
Subject: [PATCH 8/9] Fix naming convention
---
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 7ae94731234f9..a21b03132c9f0 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -180,24 +180,24 @@ const inline float distance(__detail::HLSL_FIXED_VECTOR<float, N> X,
/// \fn fvector dst( fvector, fvector)
/// \brief Returns the length of a vector
-/// \param src0 [in] The first vector contain {_, d*d, d*d, _}
-/// \param src1 [in] The second vector contain {_, 1/d, _, 1/d}
+/// \param Src0 [in] The first vector contain {_, d*d, d*d, _}
+/// \param Src1 [in] The second vector contain {_, 1/d, _, 1/d}
///
/// Return the computed distance vector contain {1, d, d*d, 1/d}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline vector<half, 4> dst(vector<half, 4> src0, vector<half, 4> src1) {
- return __detail::dst_impl(src0, src1);
+const inline vector<half, 4> dst(vector<half, 4> Src0, vector<half, 4> Src1) {
+ return __detail::dst_impl(Src0, Src1);
}
-const inline vector<float, 4> dst(vector<float, 4> src0,
- vector<float, 4> src1) {
- return __detail::dst_impl(src0, src1);
+const inline vector<float, 4> dst(vector<float, 4> Src0,
+ vector<float, 4> Src1) {
+ return __detail::dst_impl(Src0, Src1);
}
-const inline vector<double, 4> dst(vector<double, 4> src0,
- vector<double, 4> src1) {
- return __detail::dst_impl(src0, src1);
+const inline vector<double, 4> dst(vector<double, 4> Src0,
+ vector<double, 4> Src1) {
+ return __detail::dst_impl(Src0, Src1);
}
//===----------------------------------------------------------------------===//
>From 312817d5f2cead28bb2de438fcb4be76e0a1a381 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Fri, 4 Apr 2025 11:50:09 -0700
Subject: [PATCH 9/9] Add codegen with disable-llvm-passes flag
---
clang/test/CodeGenHLSL/builtins/dst.hlsl | 93 ++++++++++--------------
1 file changed, 40 insertions(+), 53 deletions(-)
diff --git a/clang/test/CodeGenHLSL/builtins/dst.hlsl b/clang/test/CodeGenHLSL/builtins/dst.hlsl
index 9e63b9ae22096..7e7fc3de02edb 100644
--- a/clang/test/CodeGenHLSL/builtins/dst.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dst.hlsl
@@ -1,70 +1,57 @@
-// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z12dstWithFloatDv4_fS_(
-// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
-// CHECK: [[VECEXT:%.*]] = extractelement <4 x float> [[P]], i64 1
-// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q]], i64 1
-// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[VECEXT]]
-// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
-// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x float> [[VECINIT]], <4 x float> [[P]], <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
-// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x float> [[VECINIT3]], <4 x float> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
-// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
-
+// CHECK-LABEL: linkonce_odr noundef nofpclass(nan inf) <4 x float> @_ZN4hlsl8__detail8dst_implIfEEDv4_T_S3_S3_(
+// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK: [[VECEXT:%.*]] = extractelement <4 x float> [[PADDR:%.*]], i32 1
+// CHECK: [[VECEXT1:%.*]] = extractelement <4 x float> [[QADDR:%.*]], i32 1
+// CHECK: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT]], [[VECEXT1]]
+// CHECK: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i32 1
+// CHECK: [[VECINIT2:%.*]] = extractelement <4 x float> [[PADDR2:%.*]], i32 2
+// CHECK: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float [[VECINIT2]], i32 2
+// CHECK: [[VECINIT4:%.*]] = extractelement <4 x float> [[QADDR3:%.*]], i32 3
+// CHECK: [[VECINIT5:%.*]] = insertelement <4 x float> [[VECINIT3]], float [[VECINIT4]], i32 3
+// CHECK-NEXT: store <4 x float> [[VECINIT5]], ptr [[DEST:%.*]], align 16
+// CHECK-NEXT: [[RES:%.*]] = load <4 x float>, ptr [[DEST]], align 16
+// CHECK-NEXT: ret <4 x float> [[RES]]
float4 dstWithFloat(float4 p1, float4 p2)
{
return dst(p1, p2);
}
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x half> @_Z11dstwithHalfDv4_DhS_(
-// CHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[P:%.*]], <4 x half> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
-// CHECK: [[VECEXT:%.*]] = extractelement <4 x half> [[P]], i64 1
-// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x half> [[Q]], i64 1
-// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[VECEXT1]], [[VECEXT]]
-// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half poison>, half [[MULRES]], i64 1
-// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x half> [[VECINIT]], <4 x half> [[P]], <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
-// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x half> [[VECINIT3]], <4 x half> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
-// CHECK-NEXT: ret <4 x half> [[VECINIT5]]
+// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <4 x half> @_ZN4hlsl8__detail8dst_implIDhEEDv4_T_S3_S3_(
+// CHECK-SAME: <4 x half> noundef nofpclass(nan inf) [[P:%.*]], <4 x half> noundef nofpclass(nan inf) [[Q:%.*]]) #[[ATTR0]] {
+// CHECK: [[VECEXT:%.*]] = extractelement <4 x half> [[PADDR:%.*]], i32 1
+// CHECK: [[VECEXT1:%.*]] = extractelement <4 x half> [[QADDR:%.*]], i32 1
+// CHECK: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[VECEXT]], [[VECEXT1]]
+// CHECK: [[VECINIT:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half poison>, half [[MULRES]], i32 1
+// CHECK: [[VECINIT2:%.*]] = extractelement <4 x half> [[PADDR2:%.*]], i32 2
+// CHECK: [[VECINIT3:%.*]] = insertelement <4 x half> [[VECINIT]], half [[VECINIT2]], i32 2
+// CHECK: [[VECINIT4:%.*]] = extractelement <4 x half> [[QADDR3:%.*]], i32 3
+// CHECK: [[VECINIT5:%.*]] = insertelement <4 x half> [[VECINIT3]], half [[VECINIT4]], i32 3
+// CHECK-NEXT: store <4 x half> [[VECINIT5]], ptr [[DEST:%.*]], align 8
+// CHECK-NEXT: [[RES:%.*]] = load <4 x half>, ptr [[DEST]], align 8
+// CHECK-NEXT: ret <4 x half> [[RES]]
half4 dstwithHalf(half4 p1, half4 p2)
{
return dst(p1, p2);
}
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> @_Z13dstWithDoubleDv4_dS_(
-// CHECK-SAME: <4 x double> noundef nofpclass(nan inf) [[P:%.*]], <4 x double> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
-// CHECK: [[VECEXT:%.*]] = extractelement <4 x double> [[P]], i64 1
-// CHECK-NEXT: [[VECEXT1:%.*]] = extractelement <4 x double> [[Q]], i64 1
-// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn double [[VECEXT1]], [[VECEXT]]
-// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x double> <double 1.000000e+00, double poison, double poison, double poison>, double [[MULRES]], i64 1
-// CHECK-NEXT: [[VECINIT3:%.*]] = shufflevector <4 x double> [[VECINIT]], <4 x double> [[P]], <4 x i32> <i32 0, i32 1, i32 6, i32 poison>
-// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x double> [[VECINIT3]], <4 x double> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
-// CHECK-NEXT: ret <4 x double> [[VECINIT5]]
+// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <4 x double> @_ZN4hlsl8__detail8dst_implIdEEDv4_T_S3_S3_(
+// CHECK-SAME: <4 x double> noundef nofpclass(nan inf) [[P:%.*]], <4 x double> noundef nofpclass(nan inf) [[Q:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK: [[VECEXT:%.*]] = extractelement <4 x double> [[PADDR:%.*]], i32 1
+// CHECK: [[VECEXT1:%.*]] = extractelement <4 x double> [[QADDR:%.*]], i32 1
+// CHECK: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn double [[VECEXT]], [[VECEXT1]]
+// CHECK: [[VECINIT:%.*]] = insertelement <4 x double> <double 1.000000e+00, double poison, double poison, double poison>, double [[MULRES]], i32 1
+// CHECK: [[VECINIT2:%.*]] = extractelement <4 x double> [[PADDR2:%.*]], i32 2
+// CHECK: [[VECINIT3:%.*]] = insertelement <4 x double> [[VECINIT]], double [[VECINIT2]], i32 2
+// CHECK: [[VECINIT4:%.*]] = extractelement <4 x double> [[QADDR3:%.*]], i32 3
+// CHECK: [[VECINIT5:%.*]] = insertelement <4 x double> [[VECINIT3]], double [[VECINIT4]], i32 3
+// CHECK-NEXT: store <4 x double> [[VECINIT5]], ptr [[DEST:%.*]], align 32
+// CHECK-NEXT: [[RES:%.*]] = load <4 x double>, ptr [[DEST]], align 32
+// CHECK-NEXT: ret <4 x double> [[RES]]
double4 dstWithDouble(double4 p1, double4 p2)
{
return dst(p1, p2);
}
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z16dstWithScalarInpff(
-// CHECK-SAME: float noundef nofpclass(nan inf) [[P:%.*]], float noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
-// CHECK: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[Q]], [[P]]
-// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
-// CHECK-NEXT: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float [[P]], i64 2
-// CHECK-NEXT: [[VECINIT5:%.*]] = insertelement <4 x float> [[VECINIT3]], float [[Q]], i64 3
-// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
-float4 dstWithScalarInp(float a, float b)
-{
- return dst(a, b);
-}
-
-// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z22dstWithScalarAndVectorfDv4_f(
-// CHECK-SAME: float noundef nofpclass(nan inf) [[P:%.*]], <4 x float> noundef nofpclass(nan inf) [[Q:%.*]]) local_unnamed_addr #[[ATTR0]] {
-// CHECK: [[VECEXT1:%.*]] = extractelement <4 x float> [[Q:%.*]], i64 1
-// CHECK-NEXT: [[MULRES:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[VECEXT1]], [[P]]
-// CHECK-NEXT: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i64 1
-// CHECK-NEXT: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float %a, i64 2
-// CHECK-NEXT: [[VECINIT5:%.*]] = shufflevector <4 x float> [[VECINIT3]], <4 x float> [[Q]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
-// CHECK-NEXT: ret <4 x float> [[VECINIT5]]
-float4 dstWithScalarAndVector(float a, float4 b)
-{
- return dst(a, b);
-}
\ No newline at end of file
More information about the cfe-commits
mailing list