Skip to content

Commit 52dee29

Browse files
committed
scalar type must match vector
1 parent 7f1a786 commit 52dee29

File tree

3 files changed

+12
-32
lines changed

3 files changed

+12
-32
lines changed

clang/lib/Headers/hlsl/hlsl_compat_overloads.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,31 @@ clamp(U p0, V p1, W p2) {
5858
// max builtin overloads
5959
//===----------------------------------------------------------------------===//
6060

61-
template <typename T, typename U, uint N>
62-
constexpr __detail::enable_if_t<
63-
__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
64-
max(vector<T, N> p0, U p1) {
61+
template <typename T, uint N>
62+
constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
63+
max(vector<T, N> p0, T p1) {
6564
return max(p0, (vector<T, N>)p1);
6665
}
6766

68-
template <typename T, typename U, uint N>
69-
constexpr __detail::enable_if_t<
70-
__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
71-
max(U p0, vector<T, N> p1) {
67+
template <typename T, uint N>
68+
constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
69+
max(T p0, vector<T, N> p1) {
7270
return max((vector<T, N>)p0, p1);
7371
}
7472

7573
//===----------------------------------------------------------------------===//
7674
// min builtin overloads
7775
//===----------------------------------------------------------------------===//
7876

79-
template <typename T, typename U, uint N>
80-
constexpr __detail::enable_if_t<
81-
__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
82-
min(vector<T, N> p0, U p1) {
77+
template <typename T, uint N>
78+
constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
79+
min(vector<T, N> p0, T p1) {
8380
return min(p0, (vector<T, N>)p1);
8481
}
8582

86-
template <typename T, typename U, uint N>
87-
constexpr __detail::enable_if_t<
88-
__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
89-
min(U p0, vector<T, N> p1) {
83+
template <typename T, uint N>
84+
constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
85+
min(T p0, vector<T, N> p1) {
9086
return min((vector<T, N>)p0, p1);
9187
}
9288

clang/test/CodeGenHLSL/builtins/max.hlsl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,3 @@ double4 test_max_double4_mismatch(double4 p0, double p1) { return max(p0, p1); }
163163
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_max_double4_mismatch2
164164
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.maxnum.v4f64
165165
double4 test_max_double4_mismatch2(double4 p0, double p1) { return max(p1, p0); }
166-
167-
// CHECK-LABEL: define noundef <2 x i32> {{.*}}test_overloads1
168-
// CHECK: call <2 x i32> @llvm.smax.v2i32
169-
int2 test_overloads1(int2 p0, float p1) { return max(p0, p1); }
170-
171-
// CHECK-LABEL: define noundef <2 x i32> {{.*}}test_overloads2
172-
// CHECK: call <2 x i32> @llvm.smax.v2i32
173-
int2 test_overloads2(int2 p0, float p1) { return max(p1, p0); }

clang/test/CodeGenHLSL/builtins/min.hlsl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,3 @@ double4 test_min_double4_mismatch(double4 p0, double p1) { return min(p0, p1); }
163163
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_min_double4_mismatch2
164164
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.minnum.v4f64
165165
double4 test_min_double4_mismatch2(double4 p0, double p1) { return min(p1, p0); }
166-
167-
// CHECK-LABEL: define noundef <2 x i32> {{.*}}test_overloads1
168-
// CHECK: call <2 x i32> @llvm.smin.v2i32
169-
int2 test_overloads1(int2 p0, float p1) { return min(p0, p1); }
170-
171-
// CHECK-LABEL: define noundef <2 x i32> {{.*}}test_overloads2
172-
// CHECK: call <2 x i32> @llvm.smin.v2i32
173-
int2 test_overloads2(int2 p0, float p1) { return min(p1, p0); }

0 commit comments

Comments
 (0)