[Bug tree-optimization/126460] New: [17 Regression] wrong code with ((T)A) +- CST -> (T)(A +- CST) fold

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

            Bug ID: 126460
           Summary: [17 Regression] wrong code with ((T)A) +- CST -> (T)(A
                    +- CST) fold
           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 long
f (int x)
{
  unsigned int u = (unsigned int) x + 1u;   /* modular, defined */
  int a = (int) u;                          /* GCC: reduction modulo 2^32 */
  return (unsigned long long) a - 1;
}

int
main (void)
{
  if (sizeof (int) == 4 && sizeof (long long) == 8
      && f (__INT_MAX__) != 0xffffffff7fffffffULL)
    __builtin_abort ();
  return 0;
}

aborts at -O1 and above with GCC 17
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.