[Bug tree-optimization/126456] New: [14/15/16/17 Regression] Wrong code with minmax folding

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

            Bug ID: 126456
           Summary: [14/15/16/17 Regression] Wrong code with minmax
                    folding
           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
  Target Milestone: ---

__attribute__((noipa)) int
min_le (int a, int c)
{
  return (a <= 6) ? (a < c ? a : c) : (5 < c ? 5 : c);
}

__attribute__((noipa)) int
max_ge (int a, int c)
{
  return (a >= 4) ? (a > c ? a : c) : (5 > c ? 5 : c);
}

int
main (void)
{
  if (min_le (6, 10) != 6)
    __builtin_abort ();
  if (max_ge (4, 0) != 4)
    __builtin_abort ();
  return 0;
}

This code aborts on aarch64 at all -O levels since GCC 14, but runs fine on GCC
13
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.