[Bug tree-optimization/109581] [13/14 Regression] Comparing with -HUGE_VAL wrong result

2023-04-21 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109581

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
This is certainly not new behavior in GCC, value range propagation handling
floating point is new, but GCC has always for -ffinite-math-only assumed
infinities and NaNs don't appear in many places.
There is no place to emit the warning you'd like to see, the ranges simply
don't include infinities and NaNs when command line options promise they won't
appear, when actually folding the comparison the compiler doesn't really know
why the range is the way it is, whether it is from the above option, or just
because the code is guarded with if (!__builtin_isinf (x)) or any other way how
to assert why in a particular code path infinity can't appear.

[Bug tree-optimization/109581] [13/14 Regression] Comparing with -HUGE_VAL wrong result

2023-04-20 Thread daschuer at mixxx dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109581

--- Comment #3 from Daniel Schürmann  ---
I can confirm that -fno-finite-math-only fixes the issue. 

Since this a new behavior in GCC 13 and it is also a hard to find issue, which
took us many hours to dig it down, it would be nice tho have at least a warning
something like: 

warning: comparison of infinity constant is always false.

The issue is that this happens silently after a compiler update. It can cause
real live issues, but is only recognized by a chance in a big code base. 

Is there a use case of explicit compare with HUGE_VAL/-HUGE_VAL and than
disable it with -ffinite-math-only?

[Bug tree-optimization/109581] [13/14 Regression] Comparing with -HUGE_VAL wrong result

2023-04-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109581

--- Comment #2 from Andrew Pinski  ---
>From evrp:
Folding predicate inf.2_3 <
-1.79769313486231570814527423731704356798070567525844996599e+308 to 0
Removing basic block 3
Merging blocks 2 and 4

Because there is nothing smaller than that with -ffinite-math-only really.

[Bug tree-optimization/109581] [13/14 Regression] Comparing with -HUGE_VAL wrong result

2023-04-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109581

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from Andrew Pinski  ---
 -ffast-math implies -ffinite-math-only which implies INF will not show up.
"Allow optimizations for floating-point arithmetic that assume that arguments
and results are not NaNs or +-Infs."
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Optimize-Options.html#index-ffinite-math-only

[Bug tree-optimization/109581] [13/14 Regression] Comparing with -HUGE_VAL wrong result

2023-04-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109581

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |13.0
  Component|c   |tree-optimization
   Keywords||wrong-code
Summary|Comparing with -HUGE_VAL|[13/14 Regression]
   |wrong result|Comparing with -HUGE_VAL
   ||wrong result
 CC||aldyh at gcc dot gnu.org