[cfe-dev] fast-math, clang-6+ and floating point exceptions

Nicholas Devenish via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 31 09:04:37 PDT 2019


On Wed, Jul 31, 2019 at 2:07 PM <paul.robinson at sony.com> wrote:
> > - Can I prevent this from happening, even with -ffast-math enabled?
>
> We do the equivalent of `-mllvm -speculate-one-expensive-inst=false`
> and it helps.

Someone has put a noop redundant function call in the middle and that
tricks the optimizer into not doing this transform, but it's not
exactly an elegant or obvious solution.

I was also surprised to see that /both directions/ of __builtin_expect
caused it to not apply the transform - even though I'd naively expect
the "True" case to result in exactly the same optimization
assumptions.

> > - Is this sort of configuration sensible or insane?
>
> In the golden land of perfect understanding of FP exceptions, it would
> be controllable in a more complete and principled way.  LLVM is a long
> way off from that.

Was more asking about, this approach of catching/crashing on all FPE's
- I've seen it before but not completely understood (or believed) the
reasons why.

Nick



More information about the cfe-dev mailing list