https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126545
liu zhenyu <lzy20000419 at outlook dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lzy20000419 at outlook dot com
--- Comment #5 from liu zhenyu <lzy20000419 at outlook dot com> ---
A smaller testcase that needs no range setup:
```c
__attribute__((noipa)) int f (double a, double b, double c)
{
if (!(a < b))
if (!(b < c))
return a < c;
return -1;
}
int main (void)
{
if (f (1.0, __builtin_nan (""), 2.0) != 1)
__builtin_abort ();
return 0;
}
```
```
$ gcc -O1 t.c && ./a.out
Aborted
$ gcc -O2 t.c && ./a.out
Aborted
```
Expected: f returns 1 (b is NaN, so both conditions hold and 1.0 < 2.0). Fails
at -O1 and -O2 with 14.2.0 and 17.0.0 (20261105). The `<=` form (`!(a <= b)`,
`!(b <= c)`, `a <= c`) fails the same way on trunk.
The trunk -O1 dom2 dump shows "Registering value_relation (a_3(D) >= b_4(D)) on
(2->3)" and "Registering value_relation (b_4(D) >= c_5(D)) on (3->4)", and then
"Replaced redundant expr 'a_3(D) < c_5(D)' with '0'". As in comment 2, the
false edge of `a < b` only gives UNGE when b may be NaN, so GE is registered
and the transitive GE a, c is wrong.
Disclaimer: This test case was found with LLM-assisted targeted testing, and
the report was written with LLM assistance.