[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 19 10:51:19 PDT 2024


MaskRay wrote:

> > > @MaskRay Are you OK with this change?
> > 
> > 
> > Sorry for the delay. I've read through [discourse.llvm.org/t/making-ffp-model-fast-more-user-friendly/78402](https://discourse.llvm.org/t/making-ffp-model-fast-more-user-friendly/78402), how we ended up with `-ffp-contract=fast-honor-pragmas` beside `=fast` (GCC compatibility, sigh), some notes that ICC/GCC have behavior differences. A different, safer mode for `-ffp-model` (absent from GCC) makes sense to me.
> 
> GCC doesn't support the pragma, and ICC doesn't have a mode that only allows contraction within a single expression (as the C standard requires), so I don't think compatibility with the behavior of the pragma in those compilers makes sense.
> 
> I personally feel very strongly that even our -ffast-math handling should honor pragmas by default and that -ffp-contract=fast should honor pragmas (perhaps with the addition of -ffp-contract=fast-no-honor-pragmas if anyone really needs that). Someone else was surprised by this behavior earlier this year (#88633). On the other hand, we've got a bug in the front end where we crash with "#pragma STDC FP_CONTRACT DEFAULT" if you've used "-ffp-contract=fast-honor-pragmas" ([godbolt.org/z/EqE6Kn6Wf](https://godbolt.org/z/EqE6Kn6Wf)) so maybe I should hold the fp-contract change back for a future patch.

I've read https://discourse.llvm.org/t/fp-contract-fast-and-pragmas/58529 and I agree that  `fast`/`fast-honor-pragmas` could be merged and if needed, `-fast-no-honor-pragmas` could be added (I suspect that there is no such need...)

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


More information about the cfe-commits mailing list