Clang: Deprecate float support from __builtin_elementwise_max (#180885)
Now we have __builtin_elementwise_maxnum __builtin_elementwise_maximum __builtin_elementwise_maximumnum
This commit is contained in:
parent
62cfe1659e
commit
5f22decefa
@ -839,13 +839,13 @@ of different sizes and signs is forbidden in binary and ternary builtins.
|
||||
T __builtin_elementwise_copysign(T x, T y) return the magnitude of x with the sign of y. floating point types
|
||||
T __builtin_elementwise_fmod(T x, T y) return the floating-point remainder of (x/y) whose sign floating point types
|
||||
matches the sign of x.
|
||||
T __builtin_elementwise_max(T x, T y) return x or y, whichever is larger integer and floating point types
|
||||
For floating point types, follows semantics of maxNum
|
||||
T __builtin_elementwise_max(T x, T y) return x or y, whichever is larger integer
|
||||
For floating point types, follows semantics of maxNum floating point types (deprecated)
|
||||
in IEEE 754-2008. See `LangRef
|
||||
<http://llvm.org/docs/LangRef.html#i-fminmax-family>`_
|
||||
for the comparison.
|
||||
T __builtin_elementwise_min(T x, T y) return x or y, whichever is smaller integer and floating point types
|
||||
For floating point types, follows semantics of minNum
|
||||
T __builtin_elementwise_min(T x, T y) return x or y, whichever is smaller integer
|
||||
For floating point types, follows semantics of minNum floating point types (deprecated)
|
||||
in IEEE 754-2008. See `LangRef
|
||||
<http://llvm.org/docs/LangRef.html#i-fminmax-family>`_
|
||||
for the comparison.
|
||||
|
||||
@ -155,6 +155,9 @@ Non-comprehensive list of changes in this release
|
||||
extends bit-reversal support to all standard integers type, including
|
||||
``_BitInt``
|
||||
|
||||
- Deprecated float types support from ``__builtin_elementwise_max`` and
|
||||
``__builtin_elementwise_min``.
|
||||
|
||||
New Compiler Flags
|
||||
------------------
|
||||
- New option ``-fms-anonymous-structs`` / ``-fno-ms-anonymous-structs`` added
|
||||
|
||||
@ -6297,6 +6297,8 @@ def warn_unavailable_def : Warning<
|
||||
def warn_deprecated_builtin : Warning<
|
||||
"builtin %0 is deprecated; use %1 instead">,
|
||||
InGroup<DeprecatedBuiltins>;
|
||||
def warn_deprecated_builtin_no_suggestion : Warning<"builtin %0 is deprecated">,
|
||||
InGroup<DeprecatedBuiltins>;
|
||||
def err_unavailable : Error<"%0 is unavailable">;
|
||||
def err_property_method_unavailable :
|
||||
Error<"property access is using %0 method which is unavailable">;
|
||||
|
||||
@ -3567,10 +3567,22 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
|
||||
return ExprError();
|
||||
break;
|
||||
case Builtin::BI__builtin_elementwise_min:
|
||||
case Builtin::BI__builtin_elementwise_max:
|
||||
case Builtin::BI__builtin_elementwise_max: {
|
||||
if (BuiltinElementwiseMath(TheCall))
|
||||
return ExprError();
|
||||
Expr *Arg0 = TheCall->getArg(0);
|
||||
Expr *Arg1 = TheCall->getArg(1);
|
||||
QualType Ty0 = Arg0->getType();
|
||||
QualType Ty1 = Arg1->getType();
|
||||
const VectorType *VecTy0 = Ty0->getAs<VectorType>();
|
||||
const VectorType *VecTy1 = Ty1->getAs<VectorType>();
|
||||
if (Ty0->isFloatingType() || Ty1->isFloatingType() ||
|
||||
(VecTy0 && VecTy0->getElementType()->isFloatingType()) ||
|
||||
(VecTy1 && VecTy1->getElementType()->isFloatingType()))
|
||||
Diag(TheCall->getBeginLoc(), diag::warn_deprecated_builtin_no_suggestion)
|
||||
<< Context.BuiltinInfo.getQuotedName(BuiltinID);
|
||||
break;
|
||||
}
|
||||
case Builtin::BI__builtin_elementwise_popcount:
|
||||
case Builtin::BI__builtin_elementwise_bitreverse:
|
||||
if (PrepareBuiltinElementwiseMathOneArgCall(
|
||||
|
||||
@ -238,6 +238,14 @@ void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, u
|
||||
_Complex float c1, c2;
|
||||
c1 = __builtin_elementwise_max(c1, c2);
|
||||
// expected-error@-1 {{1st argument must be a vector, integer or floating-point type (was '_Complex float')}}
|
||||
|
||||
double dr;
|
||||
dr = __builtin_elementwise_max(d, 0.0);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_max' is deprecated}}
|
||||
|
||||
float4 vr;
|
||||
vr = __builtin_elementwise_max(v, v);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_max' is deprecated}}
|
||||
}
|
||||
|
||||
void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
|
||||
@ -298,6 +306,14 @@ void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, u
|
||||
_Complex float c1, c2;
|
||||
c1 = __builtin_elementwise_min(c1, c2);
|
||||
// expected-error@-1 {{1st argument must be a vector, integer or floating-point type (was '_Complex float')}}
|
||||
|
||||
double dr;
|
||||
dr = __builtin_elementwise_min(d, 0.0);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_min' is deprecated}}
|
||||
|
||||
float4 vr;
|
||||
vr = __builtin_elementwise_min(v, v);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_min' is deprecated}}
|
||||
}
|
||||
|
||||
void test_builtin_elementwise_maximum(int i, short s, float f, double d, float4 fv, double4 dv, int3 iv, unsigned3 uv, int *p) {
|
||||
@ -1379,6 +1395,7 @@ typedef struct {
|
||||
|
||||
float3 foo(float3 a,const struct_float3* hi) {
|
||||
float3 b = __builtin_elementwise_max((float3)(0.0f), a);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_max' is deprecated}}
|
||||
return __builtin_elementwise_pow(b, hi->b.yyy);
|
||||
}
|
||||
|
||||
|
||||
@ -12,8 +12,6 @@ struct false_type {
|
||||
template <class T> struct is_const : false_type {};
|
||||
template <class T> struct is_const<const T> : true_type {};
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
void test_builtin_elementwise_abs() {
|
||||
const int a = 2;
|
||||
int b = 1;
|
||||
@ -64,16 +62,22 @@ void test_builtin_elementwise_max_fp() {
|
||||
const float a = 2.0f;
|
||||
float b = 1.0f;
|
||||
static_assert(!is_const<decltype(__builtin_elementwise_max(a, b))>::value);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_max' is deprecated}}
|
||||
static_assert(!is_const<decltype(__builtin_elementwise_max(b, a))>::value);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_max' is deprecated}}
|
||||
static_assert(!is_const<decltype(__builtin_elementwise_max(a, a))>::value);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_max' is deprecated}}
|
||||
}
|
||||
|
||||
void test_builtin_elementwise_min_fp() {
|
||||
const float a = 2.0f;
|
||||
float b = 1.0f;
|
||||
static_assert(!is_const<decltype(__builtin_elementwise_min(a, b))>::value);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_min' is deprecated}}
|
||||
static_assert(!is_const<decltype(__builtin_elementwise_min(b, a))>::value);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_min' is deprecated}}
|
||||
static_assert(!is_const<decltype(__builtin_elementwise_min(a, a))>::value);
|
||||
// expected-warning@-1 {{builtin '__builtin_elementwise_min' is deprecated}}
|
||||
}
|
||||
|
||||
void test_builtin_elementwise_maximum() {
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fdim(__CLC_GENTYPE x,
|
||||
__CLC_GENTYPE y) {
|
||||
return __clc_select(__builtin_elementwise_max(x - y, __CLC_FP_LIT(0.0)),
|
||||
return __clc_select(__builtin_elementwise_maxnum(x - y, __CLC_FP_LIT(0.0)),
|
||||
__CLC_GENTYPE_NAN,
|
||||
__CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y)));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user