https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128398

--- Comment #1 from liu zhenyu <lzy20000419 at outlook dot com> ---
Second testcase (same root, PRE insertion into the loop preheader rather than
hoisting; -fno-code-hoisting does not
help, -fno-tree-pre does):

```c
#define _GNU_SOURCE
#include <fenv.h>
#include <stdlib.h>
__attribute__((noipa)) void maybe_exit (int c) { if (c) exit (0); }
__attribute__((noipa)) int g (double a, double b, int n, int c)
{
  int s = 0;
  for (int i = 0; i < n; i++)
    {
      maybe_exit (c);
      s += a < b;
    }
  return s;
}
int main (void) { feenableexcept (FE_INVALID); g (__builtin_nan (""), 1.0, 10,
1); return 1; }
```

-O2: SIGFPE on 8.5.0, 9.5.0, 13.4.0, 14.2.0, 14.4.0, 15.3.0, 16.2.0, 16.2.1 and
trunk; exit 0 on 7.5.0, 10.5.0, 11.5.0,
12.5.0, and with -O2 -fno-tree-pre on trunk.

Related: PR128237 (another FP trap classification gap, gimple_could_trap_p_1
and lrint), PR29186 (general FENV code
motion), PR106408 (PRE with infinite loops). None of them covers
vn_nary_may_trap and comparisons.

Disclaimer: This test case was found with LLM-assisted targeted testing, and
the report was written with LLM assistance.

Reply via email to