[Bug tree-optimization/126502] New: [15/16/17 Regression] Wrong code with saturating idiom

"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=126502

            Bug ID: 126502
           Summary: [15/16/17 Regression] Wrong code with saturating idiom
           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
  Target Milestone: ---

__attribute__((noipa))
unsigned long sat (unsigned int x, unsigned int y)
{
  return x >= y ? (unsigned long) x - y : 0;
}

int main (void)
{
  if (sat (3000000000u, 1u) != 2999999999ul)
    __builtin_abort ();
  return 0;
}

aborts at -O2 and above on aarch64 since GCC 15
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.