[cfe-dev] fast-math, clang-6+ and floating point exceptions
Finkel, Hal J. via cfe-dev
cfe-dev at lists.llvm.org
Wed Jul 31 13:53:09 PDT 2019
On 7/31/19 11:04 AM, Nicholas Devenish via cfe-dev wrote:
> 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
>>> - 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.
We're not that far off. There's an active effort in this area and it's
pretty far along (see, e.g.,
> 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.
The primary use case I've seen is that you don't want you application,
which is supposed to be performing some numerical simulation, to run for
an extended period of time simply computing NaNs. And, moreover, if
something does go around and you generate a NaN, you want to know
exactly where that happened. LLVM doesn't really support this yet, but I
think that it's a perfectly-reasonable use case.
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory
More information about the cfe-dev