https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93945

            Bug ID: 93945
           Summary: [9/10 Regression] memset of non-zero constant followed
                    by bitfield read big-endian miscompilation since
                    r9-547
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

I think since r9-547-gb72feab889cd7925fab59771269638fcc88bc195 we miscompile
following testcase on big-endian (verified on powerpc64-linux) at -O2:
union U { char a[8]; struct S { unsigned int b : 8, c : 13, d : 11; } e; } u;

__attribute__((noipa)) int
foo (void)
{
  __builtin_memset (&u.a, 0xf4, sizeof (u.a));
  return u.e.c;
}

__attribute__((noipa)) int
bar (void)
{
  asm volatile ("" : : "g" (&u) : "memory");
  return u.e.c;
}

int
main ()
{
  int a = foo ();
  __builtin_memset (&u.a, 0xf4, sizeof (u.a));
  int b = bar ();
  if (a != b)
    __builtin_abort ();
  return 0;
}

Reply via email to