https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86509
Bug ID: 86509
Summary: Invalid conversion of comparison with infinity
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ubizjak at gmail dot com
Target Milestone: ---
Following testcase, derived from testsuite/gcc.dg/torture/inf-compare-7.c fails
on alpha due to invalid conversion of (NaN != Infinity) to (NaN < Infinity):
--cut here--
#include <fenv.h>
extern void abort (void);
extern void exit (int);
volatile double x = __builtin_nan ("");
volatile int i;
int
main (void)
{
i = x != __builtin_inf ();
if (fetestexcept (FE_INVALID))
abort ();
}
--cut here--
The _.optimized tree dump shows:
x.0_1 ={v} x;
_2 = x.0_1 > 1.79769313486231570814527423731704356798070567525844996599e+308;
_3 = ~_2;
_4 = (int) _3;
i ={v} _4;
and the comparison gets compiled to:
cmptlt/su $f12,$f11,$f10
Please note that cmptlt and cmptle insns trap with NaN argument, while cmpteq
and cmptun don't.
Please note that when using:
i = x != 1e308;
compiler compiles via:
x.0_1 ={v} x;
_2 = x.0_1 !=
1.00000000000000001097906362944045541740492309677311846337e+308;
_3 = (int) _2;
i ={v} _3;
to
cmpteq/su $f12,$f11,$f10
which doesn't trap.