https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103193
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64-*-* i?86-*-*
Component|target |middle-end
Ever confirmed|0 |1
CC| |rguenth at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-11-12
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to [email protected] from comment #3)
> Converting from >= to == is inappropriate (because >= should raise invalid
> for all NaN operands but == should do so only for signaling NaNs). If
> that's happening in architecture-independent code, then this is an
> architecture-independent bug.
/* Simplify comparison of something with itself. For IEEE
floating-point, we can only do some of these simplifications. */
(for cmp (eq ge le)
(simplify
(cmp @0 @0)
(if (! FLOAT_TYPE_P (TREE_TYPE (@0))
|| ! HONOR_NANS (@0))
{ constant_boolean_node (true, type); }
(if (cmp != EQ_EXPR)
(eq @0 @0)))))
does this. The folding to == happens unconditionally. As I understand you
the condition that applies to the constant folding should apply to the
folding to EQ as well, which means we effectively need to remove the
canonicalization to EQ (since when it would be valid we can fold to constant
true)?
There are similar transforms following:
(for cmp (unle unge uneq)
(simplify
(cmp @0 @0)
{ constant_boolean_node (true, type); }))
(for cmp (unlt ungt)
(simplify
(cmp @0 @0)
(unordered @0 @0)))
(simplify
(ltgt @0 @0)
(if (!flag_trapping_math)
{ constant_boolean_node (false, type); }))