[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 13:59:19 PST 2024


jyknight wrote:

> You'll get different results depending on whether the input is implicitly flushed in fcmp vs. not in the is.fpclass

This sounds intuitively like the sort of semantics-breaking optimization which is expected from `-ffast-math`. If the only issues are things like getting a slightly-wrong answer from is.fpclass if you somehow pass a denormal to it, when you've disabled denormal handling...that just doesn't seem so bad.

> Arguably, the only safe value is dynamic (compiler doesn't know what it's set to).

Yes, we could change the default to "dynamic" for _all_ builds (except on platforms where FTZ/DAZ flags don't exist). Potentially doing so is justified regardless of `-ffast-math`, since users can of course use `fesetenv` or `_mm_setcsr` to enable these flags themselves. (Sidenote: "dynamic" isn't even [documented](https://clang.llvm.org/docs/UsersManual.html#cmdoption-fdenormal-fp-math)). 

> So it's a matter of which behavior is going to be the least likely to be incorrect in practice.

So, alternatively...we could just go with the simplest solution, and use "ieee" as the default even under `-ffast-math`.

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


More information about the cfe-commits mailing list