Set __FLT_EVAL_METHOD__/__FLT_EVAL_METHOD_TS_18661_3__ to FLT_EVAL_METHOD_PROMOTE_TO_FLOAT when FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16.
Commit Message
Since FLT_EVAL_METHOD only accepts negative value, 0, 1 or 2.
gcc/c-family/ChangeLog:
PR c/100854
* c-common.c (excess_precision_mode_join): Return
FLT_EVAL_METHOD_PROMOTE_TO_FLOAT when both x and y are
FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16.
---
gcc/c-family/c-common.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Mon, 27 Dec 2021, liuhongt via Gcc-patches wrote:
> Since FLT_EVAL_METHOD only accepts negative value, 0, 1 or 2.
>
> gcc/c-family/ChangeLog:
>
> PR c/100854
> * c-common.c (excess_precision_mode_join): Return
> FLT_EVAL_METHOD_PROMOTE_TO_FLOAT when both x and y are
> FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16.
This patch is incorrect. The function excess_precision_mode_join
correctly implements the semantics defined in the comment above the
function, resulting in the correct value of FLT_EVAL_METHOD being defined
in <float.h> (taking proper account of whether C23 values for
FLT_EVAL_METHOD are permitted or not, including the
-fpermitted-flt-eval-methods= option).
@@ -8842,6 +8842,10 @@ excess_precision_mode_join (enum flt_eval_method x,
|| y == FLT_EVAL_METHOD_UNPREDICTABLE)
return FLT_EVAL_METHOD_UNPREDICTABLE;
+ /* FLT_EVAL_METHOD only accepts negative values, 0, 1 or 2, but
+ FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 is 16. */
+ if (x == y && x == FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16)
+ return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT;
/* GCC only supports one interchange type right now, _Float16. If
we're evaluating _Float16 in 16-bit precision, then flt_eval_method
will be FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16. */