https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126545
Bug ID: 126545
Summary: [16/17 Regression] Wrong code with ranger and FP
comparisons and NaN handling
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
Target Milestone: ---
__attribute__((noipa)) int
f (int i, int j, int k)
{
double z = 0.5 + (double) (k & 7); /* [0.5, 7.5], never a NaN */
double a = (double) ((i & 3) - 1); /* [-1, 2] */
double y = __builtin_sqrt (a); /* [-0.0, 1.4142] +-NAN */
double x = (double) (j & 7); /* [0, 7], never a NaN */
if (y < x)
return 0;
/* claimed by op1_op2_relation: y >= x */
if (z < y)
return 1;
/* claimed: z >= y, so transitively z >= x */
if (z >= x)
return 2;
return 3;
}
int
main (void)
{
/* y = sqrt (-1.0) = NaN, so both y < x and z < y are false.
x = 7.0, z = 0.5, and 0.5 >= 7.0 is false. */
if (f (0, 7, 0) != 3)
__builtin_abort ();
return 0;
}
aborts on aarch64 at -O2 and passes at -O0