[llvm-dev] [cfe-dev] Should isnan be optimized out in fast-math mode?
antlists via llvm-dev
llvm-dev at lists.llvm.org
Mon Sep 20 13:46:35 PDT 2021
On 20/09/2021 20:59, Chris Tetreault via llvm-dev wrote:
> > Exactly. Leaving `isnan` in the code makes compiler behavior more
> consistent and convenient for users. Clang also can go this way.
>
> It is never a good idea to rely on implementation details when the
> documentation states otherwise. Just because MSVC and ICC **just happen
> to** work as you’d like clang to **today**, doesn’t mean that they will
> tomorrow. Their docs state this clearly. Dereferencing a pointer you
> just freed just happens to work sometimes too, but I can’t think of
> anybody who would use this as a basis for an argument that
> use-after-free is a reasonable use case.
And the trouble with that is that what YOU want, isn't necessarily what
SOMEONE ELSE wants.
>
> > I described the concerns in the reply to Mehdi Amini's message.
>
> I did read your response to Mehdi. You said “It could mitigate the
> problem if it were implemented”. You then went on to reiterate all your
> other arguments, completely ignoring a clean solution.
>
> Adding a pragma is what’s most convenient for users. That way they can
> opt into, or opt out of, having their isnan calls being candidates for
> optimization. If clang guaranteed that isnan(x) would not be optimized
> out, then I cannot use a pragma to force it to be an optimization
> candidate. If clang keeps its current behavior, then a new fast-math
> pragma can be used to ensure that it is not optimized out. It’s the most
> flexible solution.
>
I know I may be coming in at half cock, but what is the CORRECT
MATHEMATICAL behaviour? (Yes I know there may be multiple "correct"
behaviours.) Users should always be able to select a "correct"
behaviour, and one of them should be the default, not copying some other
implemention just because "they did it thataway". Iirc excel used to
accept 29 Feb 1900 as a valid date - that's no reason for all the other
spreadsheets to get it wrong, too ...
(MY "correct" hobby horse - I'd like "divide by zero" to return
"infinity" and "divide by infinity" return "zero", because that way the
origin does not have special status and it makes maths much easier. I've
heard a bunch of reasons why I'm wrong, but should changing the
co-ordinate system really alter the result of a mathematical operation?
Didn't Einstein say everything is relative? There is nothing special
about any observation point?)
Cheers,
Wol
More information about the llvm-dev
mailing list