[Bug tree-optimization/126458] New: Wrong code with bitint

"ktkachov at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126458

            Bug ID: 126458
           Summary: Wrong code with bitint
           Product: gcc
           Version: 16.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: ---

Testcase:
typedef unsigned _BitInt(33) u33;

__attribute__((noipa)) int
neg (unsigned int a)
{
  return ((int) a) < 0;
}

__attribute__((noipa)) u33
fref (unsigned int a)
{
  return neg (a) ? (u33) a : (u33) 4294967295u;
}

__attribute__((noipa)) u33
f (unsigned int a)
{
  return ((int) a) < 0 ? (u33) a : (u33) 4294967295u;
}

int
main (void)
{
  static const unsigned int v[] = { 0x80000000u, 0xfffffffeu, 0x7fffffffu, 0u
};

  for (unsigned i = 0; i < sizeof v / sizeof v[0]; i++)
    if (f (v[i]) != fref (v[i]))
      __builtin_abort ();
  return 0;
}

This aborts with GCC on aarch64, but passes with Clang
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.