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

Reply via email to