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

            Bug ID: 127904
           Summary: [14/15/16/17 Regression] Wrong code with BitInt
           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
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

The following code aborts at -O2 on aarch64 but passes with -O0
/* After loop header copying x is dead before the inner loop.  Its copies
   must not overwrite a or b.  */

#if __BITINT_MAXWIDTH__ >= 575
typedef unsigned _BitInt(575) B;

[[gnu::noipa]] B
f (B a, B b, int c, unsigned n)
{
  B r = 0;
  for (unsigned i = 0; i < n; i++)
    {
      B x;
      if (c)
       x = a;
      else
       x = b;
      for (unsigned j = 0; j < n; j++)
       x = (B) j;
      r += x;
    }
  return r + a + b;
}
#endif

int
main ()
{
#if __BITINT_MAXWIDTH__ >= 575
  if (f (5, 7, 0, 2) != 14 || f (5, 7, 1, 3) != 18)
    __builtin_abort ();
#endif
}

Reply via email to