[cfe-dev] -fdenormal-fp-math

Hal Finkel via cfe-dev cfe-dev at lists.llvm.org
Sun Mar 12 06:52:01 PDT 2017


On 03/10/2017 08:41 AM, Jonathan 'Rynn' Sauer via cfe-dev wrote:
> Hello,
>
>>>   Does the start-up code, if any, perhaps in compiler-rt, enable the appropriate bits in the proper control register?  How can I help?
>> No. Right now, I believe that flag is taken as a statement about what the compiler can assume about the FP environment. It is not something we attempt to ensure at startup. I imagine we could on some systems (as you say, by using some startup code).
> There is a PR related to this: https://bugs.llvm.org//show_bug.cgi?id=14024

That's a good point. On some systems at least, we link in crtfastmath.o 
(which might enable flushing denormals) if -ffast-math (or friends) are 
provided when we're linking.

  -Hal

>
>> clang does not set DAZ flag in -ffast-math mode
>> As can be seen the gcc produced binary is a lot faster than clang in -ffast-mode (besides being a little bit faster in general). This is not caused by better optimizations, but because gcc links in a small function into the resulting binary, which sets the DAZ register.
>> DAZ tells the CPU to force all Denormals to zero. A Denormal is a number that is so small that FPU can't renormalize it due to limited exponent ranges. They're just like normal numbers, but they take considerably longer to process. Note that not all processors support DAZ.
>
> CU,
> Jonathan
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory




More information about the cfe-dev mailing list