[Bug tree-optimization/126504] New: Wrong code with bitint bit test

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

            Bug ID: 126504
           Summary: Wrong code with bitint bit test
           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
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

typedef unsigned _BitInt(4) u4;

/* Matched by match.pd:5457 and also by match.pd:5290.  */
__attribute__((noipa)) int f (u4 n) { return ((1 << n) & (1 << 20)) != 0; }

/* The nop_convert makes this reachable only through match.pd:5457.  */
__attribute__((noipa)) int g (u4 n)
{
  return ((unsigned) (1 << n) & (1u << 20)) != 0;
}

int main (void)
{
  for (unsigned i = 0; i < 16; i++)
    {
      if (f ((u4) i))
        __builtin_abort ();
      if (g ((u4) i))
        __builtin_abort ();
    }
  return 0;
}

aborts on aarch64 at all opt levels while 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.