[Bug tree-optimization/126564] [13/14/15/16/17 Regression] Wrong code with spaceship_replacement since r12-964

"jakub at gcc dot gnu.org via Gcc-bugs" <[email protected]> Mon, 03 Aug 2026 14:25:38 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126564

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[16/17 Regression] Wrong    |[13/14/15/16/17 Regression]
                   |code with                   |Wrong code with
                   |spaceship_replacement since |spaceship_replacement since
                   |r16-3474                    |r12-964
   Target Milestone|16.2                        |13.5

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If the
[[gnu::noipa]] int
foo (int x, int y)
{
  int c =3D -128;
  if (x =3D=3D y)
    c =3D 0;
  else if (x < y)
    c =3D -1;
  else if (x <=3D y)
    c =3D 1;
  return c > 0;
}

int
main ()
{
  int i, j;
  for (i =3D -3; i <=3D 3; i++)
    for (j =3D -3; j <=3D 3; j++)
      if (foo (i, j) !=3D 0)
        __builtin_abort ();
}
testcase for 16/17 is changed to
__attribute__((noipa)) int
foo (int x, int y)
{
  int c =3D 2;
  if (x =3D=3D y)
    c =3D 0;
  else if (x < y)
    c =3D -1;
  else if (x <=3D y)
    c =3D 1;
  return c =3D=3D 1;
}

int
main ()
{
  int i, j;
  for (i =3D -3; i <=3D 3; i++)
    for (j =3D -3; j <=3D 3; j++)
      if (foo (i, j) !=3D 0)
        __builtin_abort ();
}
for older gcc versions, it fails all the way back to
r12-964-gf1c777f40aa0b6941efc7440495a8d7e0cc2a1bb=