================
@@ -54,5 +54,67 @@ clamp(U p0, V p1, W p2) {
   return clamp(p0, (U)p1, (U)p2);
 }
 
+//===----------------------------------------------------------------------===//
+// max builtin overloads
+//===----------------------------------------------------------------------===//
+
+template <typename T, typename U, uint N>
+constexpr __detail::enable_if_t<
+    __detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
+max(vector<T, N> p0, U p1) {
+  return max(p0, (vector<T, N>)p1);
+}
+
+template <typename T, typename U, uint N>
+constexpr __detail::enable_if_t<
+    __detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
+max(U p0, vector<T, N> p1) {
+  return max((vector<T, N>)p0, p1);
+}
+
+template <typename T, typename R, uint N>
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
+max(vector<T, N> p0, vector<R, N> p1) {
----------------
llvm-beanz wrote:

I think this overload is a compatibility problem. It is better to error than to 
cause different behavior.
```hlsl
export float4 fn(int4 I, float4 F) {
    return max(I, F); // calls max(float4, float4)
}
```
see: https://hlsl.godbolt.org/z/xWPfza7d4

https://github.com/llvm/llvm-project/pull/131666
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to