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

Reply via email to