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

            Bug ID: 103905
           Summary: [12 Regression] Miscompiled i386-expand.c with
                    -march=bdver1 and -O3 since r12-1789-g836328b2c99f5b8d
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: rguenth at gcc dot gnu.org, uros at gcc dot gnu.org
  Target Milestone: ---

Created attachment 52119
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52119&action=edit
test-case

It's follow up of what I started tracking in PR92860.

$ g++ /tmp/i386-expand.ii -march=bdver1 -O3 -c -Wno-narrowing

is miscompiled so that the following test-case crashes when run with the
miscompiled compiler:

$ $ cat options-save2.ii
char flags[16];

int one = 1, two = 2;

void
__attribute__ ((noipa))
save() {
  flags[0] = one;
  flags[1] = one;
  flags[2] = one;
  flags[3] = one;
  flags[4] = one;
  flags[5] = one;
  flags[6] = one;
  flags[7] = one;
  flags[8] = one;
  flags[9] = one;
  flags[10] = one;
  flags[11] = one;
  flags[12] = one;
  flags[13] = one;
  flags[14] = one;
  flags[15] = two;
}

int
main()
{
  save ();

  __builtin_printf ("flags[0]=%d, flags[15]=%d\n", flags[0], flags[15]);
  if (flags[15] != 2)
    __builtin_abort ();

  return 0;
}

One needs here -O2 -march=core2.

Reply via email to