[Bug middle-end/106819] [13 Regression] NaN != NaN comparisons return false at -O2 since r13-2338
aldyh at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Sep 3 13:59:41 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106819
--- Comment #4 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> Global Exported: iftmp.2_6 = [frange] double [0.0, 0.0] !SIGN
> Folding PHI node: iftmp.2_6 = PHI <0.0(4), Nan(5)>
> Queued PHI for removal. Folds to: 0.0
>
> doesn't look correct. It is a range [0,0] or NaN, so it shouldn't be
> singleton_p and shouldn't fold to 0.0.
> BTW, regarding sign, generally NaNs can have either sign, though in this
> testcase we know the sign is clear (positive NaN). Not sure how much we can
> rely on that though, say if the NaN would be sNaN with known sign bit set,
> it could raise an exception and be replaced by canonical qNaN which doesn't
> have sign set.
Hmmm, I haven't really thought about signs on NaNs:
# iftmp.2_6 = PHI <0.0(4), Nan(5)>
iftmp.2_6 : [frange] double [0.0, 0.0] !SIGN
This means we have a known positive 0.0 or a NAN, but the !SIGN only applies to
the range not the NAN.
Out of curiosity, how would be know a NAN is positive or negative? Is there a
builtin that tells us that? Perhaps we could use another frange property to
model that (NAN_SIGN??).
I'm way out of my depth here (as usual -)).
More information about the Gcc-bugs
mailing list