Re: [Questions] Is there any bit in gimple/rtl to indicate this IR support fast-math or not?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 14, 2021 at 9:00 AM Hongtao Liu via Gcc-patches
<gcc-patches@xxxxxxxxxxx> wrote:
>
> On Wed, Jul 14, 2021 at 2:39 PM Matthias Kretz <m.kretz@xxxxxx> wrote:
> >
> > On Wednesday, 14 July 2021 07:18:29 CEST Hongtao Liu via Gcc-help wrote:
> > > On Wed, Jul 14, 2021 at 1:15 PM Hongtao Liu <crazylht@xxxxxxxxx> wrote:
> > > > Hi:
> > > >   The original problem was that some users wanted the cmdline option
> > > >
> > > > -ffast-math not to act on intrinsic production code.
> >
> > This sounds like the users want intrinsics to map *directly* to the
> Thanks for the reply.
> I think the users want the mixed usage of fast-math and no-fast-math.
> > corresponding instruction. If that's the case such users should use inline
> > assembly, IMHO. If you compile a TU with -ffast-math then *all* floating-point
> > operations are affected. Yes, more control over where to use fast-math and the
> > ability to mix fast-math and no-fast-math without risking ODR violations would
> > be great. But that's a larger issue, and one that would ideally be solved in
> > WG14/WG21.
> hmm, guess it would need a lot of work.

-ffast-math decomposes to quite some flag_* and those generally are not
reflected into the IL but can be different per function (and then
prevent inlining).

There's one "related" IL feature used by the Fortran frontend - PAREN_EXPR
prevents association across it.  So for Fortran (when not -fno-protect-parens
which is enabled by -Ofast), (a + b) - b cannot be optimized to a.  Eventually
this could be used to wrap intrinsic results since most of the issues in the
end require association.  Note PAREN_EXPR isn't exposed to the C family
frontends but we could of course add a builtin-like thing for this
_Noassoc ( .... ) or so.  Note PAREN_EXPR survives -Ofast so it's the frontends
that would need to choose to emit or not emit it (or always emit it).

Note some people do like to have their intrisic code optimized, so there's
likely conflicting interest here.

Richard.

> >
> > FWIW, this is what I'd do, i.e. turn off fast-math for the function in
> > question:
> > https://godbolt.org/z/3cKq5hT1o
> >
> > --
> > ──────────────────────────────────────────────────────────────────────────
> >  Dr. Matthias Kretz                           https://mattkretz.github.io
> >  GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
> >  std::experimental::simd              https://github.com/VcDevel/std-simd
> > ──────────────────────────────────────────────────────────────────────────
>
>
>
> --
> BR,
> Hongtao




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux