[cfe-dev] fp-contract at -O0

Arthur O'Dwyer via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 19 19:44:39 PST 2020

On Wed, Feb 19, 2020 at 12:22 PM David Greene via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Stephen Canon <scanon at apple.com> writes:
> >> On Feb 18, 2020, at 2:01 PM, David Greene <greened at obbligato.org>
> wrote:
> >>
> >> There are many cases where FMA is not desired and most users don't
> >> expect fused operations at -O0 unless they specifically ask for it.
> >
> > If FMA is not desired, -ffp-contract=off or the pragma should be used
> > to disable it. -O0 is the wrong tool for that job.
> Why?  Many of our customers would be surprised to see FMAs at -O0.

Jumping in with my opinion, as this thread doesn't seem to be dying of its
own accord:

The -O0 level is supposed to be the compiler's "default" optimization level
— that is, the "simplest possible" optimization level, the fastest one, the
one that just flows through the compiler without taking any unnecessary
detours or side quests. -O0 is the level where you get *the thing that just
works*, without applying any additional post-processing to it.

In fact, film "post-processing" is a good way to think about optimization.
-O0 codegen is like the dailies <https://en.wikipedia.org/wiki/Dailies>
straight from the camera. Optimization options, -ffp-contract=whatever, and
so on, are all inputs (from the human "director-producer") to the guy who
does the post-processing, saying "take this raw footage, as it came from
the camera, and— look for some extra FMAs, or lower the ones that basic
codegen already put there, or whatever."

The innards of the compiler always look basically like this:

    if (some_option) {

The "-O0" path is *by definition* the path that does not take that `if`
branch.  I don't care if the whim is "I want more FMAs" or "I want fewer
FMAs" or "I want more spills to stack" or "I want fewer spills to stack" or
whatever. The "-O0" path is *by definition* the path that does not cater to
any whim except "I want to see the dailies as soon as possible."

Which is to say, Stephen Canon and Joerg Sonnenberger are correct.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200219/c4a1c376/attachment.html>

More information about the cfe-dev mailing list