Skip to content

Commit af5abd9

Browse files
authored
[HLSL] add extra scalar vector overloads for clamp (#129939)
Add additional vector scalar overloads for clamp using templates Add Tests fixup tests which have changed. Closes #128230
1 parent 279e82f commit af5abd9

File tree

7 files changed

+186
-13
lines changed

7 files changed

+186
-13
lines changed

clang/lib/Headers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ set(hlsl_h
8787
set(hlsl_subdir_files
8888
hlsl/hlsl_basic_types.h
8989
hlsl/hlsl_alias_intrinsics.h
90+
hlsl/hlsl_compat_overloads.h
9091
hlsl/hlsl_intrinsic_helpers.h
9192
hlsl/hlsl_intrinsics.h
9293
hlsl/hlsl_detail.h

clang/lib/Headers/hlsl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
// HLSL standard library function declarations/definitions.
2424
#include "hlsl/hlsl_alias_intrinsics.h"
25+
#include "hlsl/hlsl_compat_overloads.h"
2526
#include "hlsl/hlsl_intrinsics.h"
2627

2728
#if defined(__clang__)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//===--- hlsl_compat_overloads.h - Extra HLSL overloads for intrinsics --===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _HLSL_COMPAT_OVERLOADS_H_
10+
#define _HLSl_COMPAT_OVERLOADS_H_
11+
12+
namespace hlsl {
13+
14+
// Note: Functions in this file are sorted alphabetically, then grouped by base
15+
// element type, and the element types are sorted by size, then singed integer,
16+
// unsigned integer and floating point. Keeping this ordering consistent will
17+
// help keep this file manageable as it grows.
18+
19+
//===----------------------------------------------------------------------===//
20+
// clamp builtins overloads
21+
//===----------------------------------------------------------------------===//
22+
23+
template <typename T, typename R, typename U, uint N>
24+
constexpr __detail::enable_if_t<
25+
__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
26+
clamp(vector<T, N> p0, vector<R, N> p1, U p2) {
27+
return clamp(p0, (vector<T, N>)p1, (vector<T, N>)p2);
28+
}
29+
template <typename T, typename R, typename U, uint N>
30+
constexpr __detail::enable_if_t<
31+
__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
32+
clamp(vector<T, N> p0, U p1, vector<R, N> p2) {
33+
return clamp(p0, (vector<T, N>)p1, (vector<T, N>)p2);
34+
}
35+
template <typename T, typename U, typename V, uint N>
36+
constexpr __detail::enable_if_t<__detail::is_arithmetic<U>::Value &&
37+
__detail::is_arithmetic<V>::Value &&
38+
(N > 1 && N <= 4),
39+
vector<T, N>>
40+
clamp(vector<T, N> p0, U p1, V p2) {
41+
return clamp(p0, (vector<T, N>)p1, (vector<T, N>)p2);
42+
}
43+
template <typename T, typename R, typename S, uint N>
44+
constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
45+
clamp(vector<T, N> p0, vector<R, N> p1, vector<S, N> p2) {
46+
return clamp(p0, (vector<T, N>)p1, (vector<T, N>)p2);
47+
}
48+
template <typename U, typename V, typename W>
49+
constexpr __detail::enable_if_t<__detail::is_arithmetic<U>::Value &&
50+
__detail::is_arithmetic<V>::Value &&
51+
__detail::is_arithmetic<W>::Value,
52+
U>
53+
clamp(U p0, V p1, W p2) {
54+
return clamp(p0, (U)p1, (U)p2);
55+
}
56+
57+
} // namespace hlsl
58+
#endif // _HLSL_COMPAT_OVERLOADS_H_

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,23 @@ static bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) {
20492049
return false;
20502050
}
20512051

2052+
static bool CheckAllArgsHaveSameType(Sema *S, CallExpr *TheCall) {
2053+
assert(TheCall->getNumArgs() > 1);
2054+
QualType ArgTy0 = TheCall->getArg(0)->getType();
2055+
2056+
for (unsigned I = 1, N = TheCall->getNumArgs(); I < N; ++I) {
2057+
if (!S->getASTContext().hasSameUnqualifiedType(
2058+
ArgTy0, TheCall->getArg(I)->getType())) {
2059+
S->Diag(TheCall->getBeginLoc(), diag::err_vec_builtin_incompatible_vector)
2060+
<< TheCall->getDirectCallee() << /*useAllTerminology*/ true
2061+
<< SourceRange(TheCall->getArg(0)->getBeginLoc(),
2062+
TheCall->getArg(N - 1)->getEndLoc());
2063+
return true;
2064+
}
2065+
}
2066+
return false;
2067+
}
2068+
20522069
static bool CheckArgTypeMatches(Sema *S, Expr *Arg, QualType ExpectedType) {
20532070
QualType ArgType = Arg->getType();
20542071
if (!S->getASTContext().hasSameUnqualifiedType(ArgType, ExpectedType)) {
@@ -2400,7 +2417,8 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
24002417
case Builtin::BI__builtin_hlsl_elementwise_clamp: {
24012418
if (SemaRef.checkArgCount(TheCall, 3))
24022419
return true;
2403-
if (CheckVectorElementCallArgs(&SemaRef, TheCall))
2420+
if (CheckAnyScalarOrVector(&SemaRef, TheCall, 0) ||
2421+
CheckAllArgsHaveSameType(&SemaRef, TheCall))
24042422
return true;
24052423
if (SemaRef.BuiltinElementwiseTernaryMath(
24062424
TheCall, /*CheckForFloatArgs*/

clang/test/CodeGenHLSL/builtins/clamp.hlsl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ int16_t3 test_clamp_short3(int16_t3 p0, int16_t3 p1) { return clamp(p0, p1,p1);
2828
// NATIVE_HALF: define [[FNATTRS]] <4 x i16> @_Z17test_clamp_short4
2929
// NATIVE_HALF: call <4 x i16> @llvm.[[TARGET]].sclamp.v4i16
3030
int16_t4 test_clamp_short4(int16_t4 p0, int16_t4 p1) { return clamp(p0, p1,p1); }
31+
// NATIVE_HALF: define [[FNATTRS]] <4 x i16> {{.*}}test_clamp_short4_mismatch
32+
// NATIVE_HALF: call <4 x i16> @llvm.[[TARGET]].sclamp.v4i16
33+
int16_t4 test_clamp_short4_mismatch(int16_t4 p0, int16_t p1) { return clamp(p0, p0,p1); }
3134

3235
// NATIVE_HALF: define [[FNATTRS]] i16 @_Z17test_clamp_ushort
3336
// NATIVE_HALF: call i16 @llvm.[[TARGET]].uclamp.i16(
@@ -41,6 +44,9 @@ uint16_t3 test_clamp_ushort3(uint16_t3 p0, uint16_t3 p1) { return clamp(p0, p1,p
4144
// NATIVE_HALF: define [[FNATTRS]] <4 x i16> @_Z18test_clamp_ushort4
4245
// NATIVE_HALF: call <4 x i16> @llvm.[[TARGET]].uclamp.v4i16
4346
uint16_t4 test_clamp_ushort4(uint16_t4 p0, uint16_t4 p1) { return clamp(p0, p1,p1); }
47+
// NATIVE_HALF: define [[FNATTRS]] <4 x i16> {{.*}}test_clamp_ushort4_mismatch
48+
// NATIVE_HALF: call <4 x i16> @llvm.[[TARGET]].uclamp.v4i16
49+
uint16_t4 test_clamp_ushort4_mismatch(uint16_t4 p0, uint16_t p1) { return clamp(p0, p0,p1); }
4450
#endif
4551

4652
// CHECK: define [[FNATTRS]] i32 @_Z14test_clamp_int
@@ -55,6 +61,9 @@ int3 test_clamp_int3(int3 p0, int3 p1) { return clamp(p0, p1,p1); }
5561
// CHECK: define [[FNATTRS]] <4 x i32> @_Z15test_clamp_int4
5662
// CHECK: call <4 x i32> @llvm.[[TARGET]].sclamp.v4i32
5763
int4 test_clamp_int4(int4 p0, int4 p1) { return clamp(p0, p1,p1); }
64+
// CHECK: define [[FNATTRS]] <4 x i32> {{.*}}test_clamp_int4_mismatch
65+
// CHECK: call <4 x i32> @llvm.[[TARGET]].sclamp.v4i32
66+
int4 test_clamp_int4_mismatch(int4 p0, int p1) { return clamp(p0, p0,p1); }
5867

5968
// CHECK: define [[FNATTRS]] i32 @_Z15test_clamp_uint
6069
// CHECK: call i32 @llvm.[[TARGET]].uclamp.i32(
@@ -68,6 +77,9 @@ uint3 test_clamp_uint3(uint3 p0, uint3 p1) { return clamp(p0, p1,p1); }
6877
// CHECK: define [[FNATTRS]] <4 x i32> @_Z16test_clamp_uint4
6978
// CHECK: call <4 x i32> @llvm.[[TARGET]].uclamp.v4i32
7079
uint4 test_clamp_uint4(uint4 p0, uint4 p1) { return clamp(p0, p1,p1); }
80+
// CHECK: define [[FNATTRS]] <4 x i32> {{.*}}test_clamp_uint4_mismatch
81+
// CHECK: call <4 x i32> @llvm.[[TARGET]].uclamp.v4i32
82+
uint4 test_clamp_uint4_mismatch(uint4 p0, uint p1) { return clamp(p0, p0,p1); }
7183

7284
// CHECK: define [[FNATTRS]] i64 @_Z15test_clamp_long
7385
// CHECK: call i64 @llvm.[[TARGET]].sclamp.i64(
@@ -81,6 +93,9 @@ int64_t3 test_clamp_long3(int64_t3 p0, int64_t3 p1) { return clamp(p0, p1,p1); }
8193
// CHECK: define [[FNATTRS]] <4 x i64> @_Z16test_clamp_long4
8294
// CHECK: call <4 x i64> @llvm.[[TARGET]].sclamp.v4i64
8395
int64_t4 test_clamp_long4(int64_t4 p0, int64_t4 p1) { return clamp(p0, p1,p1); }
96+
// CHECK: define [[FNATTRS]] <4 x i64> {{.*}}test_clamp_long4_mismatch
97+
// CHECK: call <4 x i64> @llvm.[[TARGET]].sclamp.v4i64
98+
int64_t4 test_clamp_long4_mismatch(int64_t4 p0, int64_t p1) { return clamp(p0, p0,p1); }
8499

85100
// CHECK: define [[FNATTRS]] i64 @_Z16test_clamp_ulong
86101
// CHECK: call i64 @llvm.[[TARGET]].uclamp.i64(
@@ -94,6 +109,9 @@ uint64_t3 test_clamp_ulong3(uint64_t3 p0, uint64_t3 p1) { return clamp(p0, p1,p1
94109
// CHECK: define [[FNATTRS]] <4 x i64> @_Z17test_clamp_ulong4
95110
// CHECK: call <4 x i64> @llvm.[[TARGET]].uclamp.v4i64
96111
uint64_t4 test_clamp_ulong4(uint64_t4 p0, uint64_t4 p1) { return clamp(p0, p1,p1); }
112+
// CHECK: define [[FNATTRS]] <4 x i64> {{.*}}test_clamp_ulong4_mismatch
113+
// CHECK: call <4 x i64> @llvm.[[TARGET]].uclamp.v4i64
114+
uint64_t4 test_clamp_ulong4_mismatch(uint64_t4 p0, uint64_t p1) { return clamp(p0, p0,p1); }
97115

98116
// NATIVE_HALF: define [[FNATTRS]] [[FFNATTRS]] half @_Z15test_clamp_half
99117
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn half @llvm.[[TARGET]].nclamp.f16(
@@ -115,6 +133,11 @@ half3 test_clamp_half3(half3 p0, half3 p1) { return clamp(p0, p1,p1); }
115133
// NO_HALF: define [[FNATTRS]] [[FFNATTRS]] <4 x float> @_Z16test_clamp_half4
116134
// NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].nclamp.v4f32(
117135
half4 test_clamp_half4(half4 p0, half4 p1) { return clamp(p0, p1,p1); }
136+
// NATIVE_HALF: define [[FNATTRS]] [[FFNATTRS]] <4 x half> {{.*}}test_clamp_half4_mismatch
137+
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.[[TARGET]].nclamp.v4f16
138+
// NO_HALF: define [[FNATTRS]] [[FFNATTRS]] <4 x float> {{.*}}test_clamp_half4_mismatch
139+
// NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].nclamp.v4f32(
140+
half4 test_clamp_half4_mismatch(half4 p0, half p1) { return clamp(p0, p0,p1); }
118141

119142
// CHECK: define [[FNATTRS]] [[FFNATTRS]] float @_Z16test_clamp_float
120143
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].nclamp.f32(
@@ -128,6 +151,9 @@ float3 test_clamp_float3(float3 p0, float3 p1) { return clamp(p0, p1,p1); }
128151
// CHECK: define [[FNATTRS]] [[FFNATTRS]] <4 x float> @_Z17test_clamp_float4
129152
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].nclamp.v4f32
130153
float4 test_clamp_float4(float4 p0, float4 p1) { return clamp(p0, p1,p1); }
154+
// CHECK: define [[FNATTRS]] [[FFNATTRS]] <4 x float> {{.*}}test_clamp_float4_mismatch
155+
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].nclamp.v4f32
156+
float4 test_clamp_float4_mismatch(float4 p0, float p1) { return clamp(p0, p0,p1); }
131157

132158
// CHECK: define [[FNATTRS]] [[FFNATTRS]] double @_Z17test_clamp_double
133159
// CHECK: call reassoc nnan ninf nsz arcp afn double @llvm.[[TARGET]].nclamp.f64(
@@ -141,3 +167,29 @@ double3 test_clamp_double3(double3 p0, double3 p1) { return clamp(p0, p1,p1); }
141167
// CHECK: define [[FNATTRS]] [[FFNATTRS]] <4 x double> @_Z18test_clamp_double4
142168
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.[[TARGET]].nclamp.v4f64
143169
double4 test_clamp_double4(double4 p0, double4 p1) { return clamp(p0, p1,p1); }
170+
// CHECK: define [[FNATTRS]] [[FFNATTRS]] <4 x double> {{.*}}test_clamp_double4_mismatch
171+
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.[[TARGET]].nclamp.v4f64
172+
double4 test_clamp_double4_mismatch(double4 p0, double p1) { return clamp(p0, p0,p1); }
173+
// CHECK: define [[FNATTRS]] [[FFNATTRS]] <4 x double> {{.*}}test_clamp_double4_mismatch2
174+
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.[[TARGET]].nclamp.v4f64
175+
double4 test_clamp_double4_mismatch2(double4 p0, double p1) { return clamp(p0, p1,p0); }
176+
177+
// CHECK: define [[FNATTRS]] <2 x i32> {{.*}}_overloads1
178+
// CHECK: call <2 x i32> @llvm.[[TARGET]].sclamp.v2i32
179+
int2 test_overloads1(int2 p0, float2 p1, uint p2) { return clamp(p0, p1, p2); }
180+
181+
// CHECK: define [[FNATTRS]] [[FFNATTRS]] <2 x float> {{.*}}test_overloads2
182+
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].nclamp.v2f32
183+
float2 test_overloads2(float2 p0, uint p1, int2 p2) { return clamp(p0, p1, p2); }
184+
185+
// CHECK: define [[FNATTRS]] <3 x i32> {{.*}}test_overloads3
186+
// CHECK: call <3 x i32> @llvm.[[TARGET]].uclamp.v3i32
187+
uint3 test_overloads3(uint3 p0, int p1, float p2) { return clamp(p0, p1, p2); }
188+
189+
// CHECK: define [[FNATTRS]] [[FFNATTRS]] <4 x double> {{.*}}test_overloads4
190+
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.[[TARGET]].nclamp.v4f64
191+
double4 test_overloads4(double4 p0, float4 p1, int4 p2) { return clamp(p0, p1, p2); }
192+
193+
// CHECK: define [[FNATTRS]] i32 {{.*}}test_overloads5
194+
// CHECK: call i32 @llvm.[[TARGET]].sclamp.i32(
195+
int test_overloads5(int p0, uint p1, double p2) { return clamp(p0, p1, p2); }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=half
2+
// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=half3
3+
// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=int16_t
4+
// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=int16_t3
5+
// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=uint16_t
6+
// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=uint16_t3
7+
8+
// check we error on 16 bit type if shader model is too old
9+
// CHECK: '-enable-16bit-types' option requires target HLSL Version >= 2018 and shader model >= 6.2, but HLSL Version is 'hlsl202x' and shader model is '6.0'
10+
TEST_TYPE test_half_error(TEST_TYPE p0, int p1) {
11+
return clamp(p0, p1, p1);
12+
}

clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected
1+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected=note
22

33
float2 test_no_second_arg(float2 p0) {
44
return __builtin_hlsl_elementwise_clamp(p0);
@@ -20,54 +20,85 @@ float2 test_clamp_no_second_arg(float2 p0) {
2020
// expected-error@-1 {{no matching function for call to 'clamp'}}
2121
}
2222

23+
float test_scalar_first_arg(float p0, float2 p1) {
24+
return clamp(p0, p1, p1);
25+
// expected-error@-1 {{call to 'clamp' is ambiguous}}
26+
}
27+
28+
float test_scalar_first_arg2(float p0, float2 p1) {
29+
return clamp(p0, p0, p1);
30+
// expected-error@-1 {{call to 'clamp' is ambiguous}}
31+
}
32+
33+
float2 test_scalar_first_arg3(float p0, float2 p1) {
34+
return clamp(p0, p0, p1);
35+
// expected-error@-1 {{call to 'clamp' is ambiguous}}
36+
}
37+
38+
float3 test_thing(float3 p0, float2 p1) {
39+
return clamp(p0, p0, p1);
40+
// expected-error@-1 {{cannot initialize return object of type 'float3' (aka 'vector<float, 3>') with an rvalue of type 'vector<float, 2>' (vector of 2 'float' values)}}
41+
}
42+
43+
typedef float float5 __attribute__((ext_vector_type(5)));
44+
45+
// check vectors of wrong size are rejected
46+
float5 vec_too_big(float5 p0) {
47+
return clamp(p0, p0, p0);
48+
// expected-error@-1 {{call to 'clamp' is ambiguous}}
49+
}
50+
2351
float2 test_clamp_vector_size_mismatch(float3 p0, float2 p1) {
2452
return clamp(p0, p0, p1);
2553
// expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'vector<float, 2>' (vector of 2 'float' values)}}
54+
// expected-warning@-2 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'vector<float, 2>' (vector of 2 'float' values)}}
2655
}
2756

2857
float2 test_clamp_builtin_vector_size_mismatch(float3 p0, float2 p1) {
2958
return __builtin_hlsl_elementwise_clamp(p0, p1, p1);
3059
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
3160
}
3261

62+
// allowed by the overloads in hlsl_compat_overloads.h
63+
// support for this overload might be removed in a future version of hlsl
3364
float test_clamp_scalar_mismatch(float p0, half p1) {
3465
return clamp(p1, p0, p1);
35-
// expected-error@-1 {{call to 'clamp' is ambiguous}}
3666
}
3767

68+
// allowed by the overloads in hlsl_compat_overloads.h
69+
// support for this overload might be removed in a future version of hlsl
3870
float2 test_clamp_element_type_mismatch(half2 p0, float2 p1) {
3971
return clamp(p1, p0, p1);
40-
// expected-error@-1 {{call to 'clamp' is ambiguous}}
4172
}
4273

4374
float2 test_builtin_clamp_float2_splat(float p0, float2 p1) {
4475
return __builtin_hlsl_elementwise_clamp(p0, p1, p1);
45-
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}}
76+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
4677
}
4778

4879
float3 test_builtin_clamp_float3_splat(float p0, float3 p1) {
4980
return __builtin_hlsl_elementwise_clamp(p0, p1, p1);
50-
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}}
81+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
5182
}
5283

5384
float4 test_builtin_clamp_float4_splat(float p0, float4 p1) {
5485
return __builtin_hlsl_elementwise_clamp(p0, p1, p1);
55-
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}}
86+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
5687
}
5788

5889
float2 test_clamp_float2_int_splat(float2 p0, int p1) {
5990
return __builtin_hlsl_elementwise_clamp(p0, p1, p1);
60-
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}}
91+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
6192
}
6293

6394
float3 test_clamp_float3_int_splat(float3 p0, int p1) {
6495
return __builtin_hlsl_elementwise_clamp(p0, p1, p1);
65-
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}}
96+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
6697
}
6798

6899
float2 test_builtin_clamp_int_vect_to_float_vec_promotion(int2 p0, float p1) {
69100
return __builtin_hlsl_elementwise_clamp(p0, p1, p1);
70-
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}}
101+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
71102
}
72103

73104
float test_builtin_clamp_bool_type_promotion(bool p0) {
@@ -77,15 +108,15 @@ float test_builtin_clamp_bool_type_promotion(bool p0) {
77108

78109
float builtin_bool_to_float_type_promotion(float p0, bool p1) {
79110
return __builtin_hlsl_elementwise_clamp(p0, p0, p1);
80-
// expected-error@-1 {{3rd argument must be a floating point type (was 'bool')}}
111+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
81112
}
82113

83114
float builtin_bool_to_float_type_promotion2(bool p0, float p1) {
84115
return __builtin_hlsl_elementwise_clamp(p1, p0, p1);
85-
// expected-error@-1 {{2nd argument must be a floating point type (was 'bool')}}
116+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
86117
}
87118

88119
float builtin_clamp_int_to_float_promotion(float p0, int p1) {
89120
return __builtin_hlsl_elementwise_clamp(p0, p0, p1);
90-
// expected-error@-1 {{3rd argument must be a floating point type (was 'int')}}
121+
// expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}}
91122
}

0 commit comments

Comments
 (0)