[clang] Disable FTZ/DAZ when compiling shared libraries by default. (PR #80475)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 09:00:17 PST 2024


jyknight wrote:

> It is not always safe to run preserve-sign code under IEEE settings

I can see that this is used in a bunch of optimization/constant-folding passes, but I don't have a feel for what the actual impact is:
1. Which value allows generating the "fastest" math code -- disregarding correctness? I'd assume that "dynamic" is least optimizable, "ieee" in the middle, and "preserve-sign" is likely to generate the "fastest" code?
2. What is the likely _actual_ impact of choosing the wrong value? Ie, what does "it is not always safe" mean? Is this wrong beyond what is usually expected from `-ffast-math` optimizations?

I note that we're frequently getting it wrong in the other direction today, as there are many users who link in code compiled _without_ `-ffast-math` (and thus, with `-fdenormal-fp-math=ieee`) into a binary compiled with `-ffast-math` -- which sets the fp control words to enable `MXCSR_DAZ | MXCSR_FTZ`. In addition, I think there's even more users who compile some TUs _with_ `-ffast-math`, and link that into a binary compiled without.

https://github.com/llvm/llvm-project/pull/80475


More information about the cfe-commits mailing list