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

            Bug ID: 90025
           Summary: [9 Regression] botan2 miscompilation on s390x-linux
                    since r268957
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

The following testcase is miscompiled e.g. with -O2 -march=zEC12 -mtune=z13 on
s390x-linux:

__attribute__((noipa)) void
bar (char *p)
{
  int i;
  for (i = 0; i < 6; i++)
    if (p[i] != "foobar"[i])
      __builtin_abort ();
  for (; i < 32; i++)
    if (p[i] != '\0')
      __builtin_abort ();
}

__attribute__((noipa)) void
foo (unsigned int x)
{
  char s[32] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 };
  ((unsigned int *) s)[2] = __builtin_bswap32 (x);
  bar (s);
}

int
main ()
{
  foo (0);
  return 0;
}

The problem is that since that change we emit a store_by_pieces (8 bytes)
followed by clear_storage (24 bytes), but the object we pass to the latter
actually has S1, so DSE2 then happily removes it when it sees a further store
of 4 bytes to s+8.

Reply via email to