[cfe-commits] [PATCH] Add -fexcess-precision option.

Hal Finkel hfinkel at anl.gov
Thu Jun 21 13:23:55 PDT 2012


On Thu, 21 Jun 2012 11:34:22 -0700
Chandler Carruth <chandlerc at google.com> wrote:

> On Thu, Jun 21, 2012 at 11:28 AM, Lang Hames <lhames at gmail.com> wrote:
> 
> > Hi Steve, Chandler, Hal,
> >
> >
> >> That said, I don't love overloading excess-precision for this,
> >> even if fma is formally a special case of excess precision, mostly
> >> because excess precision has even more bizarre corner cases -- it
> >> leads to such monstrosities as cos(x) != cos(x).
> >>
> >
> > Sounds like -fexcess-precision is too blunt of an instrument for
> > this. Should setting -fexcess-precision=fast enable this
> > optimization though?
> >
> 
> I'm leery of it doing anything other than allowing use of higher
> precision registers... Mostly because I don't want to ever get a bug
> report about it. ;] Others may be less reluctant though.
> 
> > If we're not going to use excess-precision, I would suggest a name
> > that is
> >> completely explicit; something along the lines of
> >> -fallow-fma-anywhere or -fallow-fma-across-expressions (those
> >> might be too wordy).
> >>
> >> "-fallow-fma-anywhere" sounds fine to me if this flag is going to
> >> be
> > targeted specifically at FMA formation. Does anybody have any
> > objections to this?
> >
> 
> > Should this flag, whatever it's eventually called, have a
> > "never-form" mode that over-rides FP_CONTRACT and prevents any FMA
> > formation? That seems like it could be useful, if only for
> > debugging. FP_CONTRACT doesn't guarantee any fusing, so a flag that
> > disabled any fusing wouldn't violate FP_CONTRACT semantics, it
> > would just provide a baseline with no fusing carried out. This is
> > what I had in mind when I penned the comments that you referred to
> > Hal.
> >
> > In that case an alternative flag could be:
> >
> > "-fform-fma={anywhere,standard,never}"
> >
> 
> I do think that "never" is an important mode. I like the term
> "strict" for that personally, but paint the bikeshed as you like.
> 
> I wouldn't restrict this to FMA though, at the very least there is a
> fused mul+sub on some architectures... How about this shade of blue
> for our favorite shed:
> 
> -ffuse-fp-ops={fast,standard,never}
> 
> Where 'fast' allows any amount of fusing, 'standard' only allows that
> which is allowed in the relevant language standard (FP_CONTRACT), and
> 'never' (or 'strict') completely disables op fusion?

I object to 'never' because there may be cases in the future where we
can determine that extra precision cannot change the result so we can
use fma while maintaining strict standard compliance. 'strict' is much
better.

For an option whose job it is to set the default FP_CONTRACT state, I
think that -ffp-contract=[no|yes|default] is the best. This makes the
one-to-one correspondence clear to the user.

We should separately support -fexcess-precision=fast to turn on
aggressive backend optimizations which might take advantage of excess
precision (such as aggressive fma formation).

 -Hal

-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the cfe-commits mailing list