public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97135] New: [11 Regression] Wrong code at -Os since r11-408-g84935c98221
@ 2020-09-21  8:36 acoplan at gcc dot gnu.org
  2020-09-21  8:53 ` [Bug tree-optimization/97135] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: acoplan at gcc dot gnu.org @ 2020-09-21  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97135
           Summary: [11 Regression] Wrong code at -Os since
                    r11-408-g84935c98221
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

For the following testcase:

long c;
long *d = &c;
int a, e, f;
int main(void) {
  for (; f <= 5; f++) {
    e = 0;
    for (; e <= 5; e++) {
      a = 1;
      for (; a <= 5; a++);
      *d = 0;
      if (f)
        break;
    }
  }
  return a;
}

Compiling with -O{0,1,2,3} (for both gcc and clang), as expected, the program
returns 6.

Compiling with -Os, the program returns 1 (since
r11-408-g84935c9822183ce403bb361c5f405711b9a808c6).

I've reproduced this on both x86 and aarch64. Interestingly, compiling with -Os
-fno-strict-aliasing, we no longer see the wrong code bug (the program returns
6). However, I believe this program is free of strict aliasing violations.

To reproduce:

$ bin/gcc wrong_code.c
$ ./a.out || echo $?
6
$ bin/gcc wrong_code.c -Os
$ ./a.out || echo $?
1
$ bin/gcc wrong_code.c -Os -fno-strict-aliasing
$ ./a.out || echo $?
6

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-22  6:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21  8:36 [Bug tree-optimization/97135] New: [11 Regression] Wrong code at -Os since r11-408-g84935c98221 acoplan at gcc dot gnu.org
2020-09-21  8:53 ` [Bug tree-optimization/97135] " jakub at gcc dot gnu.org
2020-09-21 10:38 ` rguenth at gcc dot gnu.org
2020-09-21 10:50 ` rguenth at gcc dot gnu.org
2020-09-21 12:06 ` cvs-commit at gcc dot gnu.org
2020-09-21 12:07 ` rguenth at gcc dot gnu.org
2020-09-22  6:40 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).