[PATCH 4/6] Support -fexcess-precision=16 which will enable FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 when backend supports _Float16.

Hongtao Liu crazylht@gmail.com
Tue Aug 3 02:44:08 GMT 2021


On Tue, Aug 3, 2021 at 3:34 AM Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Mon, 2 Aug 2021, liuhongt via Gcc-patches wrote:
>
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index 7979e240426..dc673c89bc8 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -23352,6 +23352,8 @@ ix86_get_excess_precision (enum excess_precision_type type)
> >       return (type == EXCESS_PRECISION_TYPE_STANDARD
> >               ? FLT_EVAL_METHOD_PROMOTE_TO_FLOAT
> >               : FLT_EVAL_METHOD_UNPREDICTABLE);
> > +      case EXCESS_PRECISION_TYPE_FLOAT16:
> > +     return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16;
> >        default:
> >       gcc_unreachable ();
> >      }
>
> I'd expect an error for -fexcess-precision=16 with -mfpmath=387 (since x87
> doesn't do float or double arithmetic, but -fexcess-precision=16 implies
> that all of _Float16, float and double are represented to the range and
> precision of their type withou any excess precision).
>
Yes, additional changes like this.

modified   gcc/config/i386/i386.c
@@ -23443,6 +23443,9 @@ ix86_get_excess_precision (enum
excess_precision_type type)
  ? FLT_EVAL_METHOD_PROMOTE_TO_FLOAT
  : FLT_EVAL_METHOD_UNPREDICTABLE);
       case EXCESS_PRECISION_TYPE_FLOAT16:
+ if (TARGET_80387
+     && !(TARGET_SSE_MATH && TARGET_SSE))
+   error ("%<-fexcess-precision=16%> is not compatible with %<-mfpmath=387%>");
  return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16;
       default:
  gcc_unreachable ();
new file   gcc/testsuite/gcc.target/i386/float16-7.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mfpmath=387 -fexcess-precision=16" } */
+/* { dg-excess-errors "'-fexcess-precision=16' is not compatible with
'-mfpmath=387'" } */
+_Float16
+foo (_Float16 a, _Float16 b)
+{
+  return a + b;/* { dg-error "'-fexcess-precision=16' is not
compatible with '-mfpmath=387'" } */
+}
+

> --
> Joseph S. Myers
> joseph@codesourcery.com



-- 
BR,
Hongtao


More information about the Gcc-patches mailing list