public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112310] New: [14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since r14-1161-g5476de2618f
@ 2023-10-31 11:13 shaohua.li at inf dot ethz.ch
  2023-10-31 12:02 ` [Bug tree-optimization/112310] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-10-31 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112310
           Summary: [14 Regression] Wrong code at -O2/3 on
                    x86_64-linux-gnu since r14-1161-g5476de2618f
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
                CC: rguenth at gcc dot gnu.org
  Target Milestone: ---

gcc at -O2/3 produces the wrong code.

Bisected to r14-1161-g5476de2618f

Compiler explorer: https://godbolt.org/z/Kb4qMKE9K

$ cat a.c
int printf(const char *, ...);
short a, b;
static int c, d, e, f = -7;
char g;
int *h = &d;
int **i = &h;
int j;
short(k)(int l) { return l >= 2 ? 0 : l; }
int(m)(int l, int n) { return l < -2147483647 / n ? l : l * n; }
void o() { &c; }
int main() {
  {
    int p;
    for (; g <= 3; g++) {
      for (; c; c++)
        ;
      a = 2;
      for (; a <= 7; a++) {
        short *r = &b;
        p = m(*h, 2022160547);
        unsigned q = 2022160547;
        e = p * q;
        *r ^= e;
        j = k(c + 3);
        **i = 0;
      }
      *i = &f;
    }
  }
  printf("%d\n", b);
}
$
$ gcc -O0 a.c && ./a.out
-3189
$ gcc -O2 a.c && ./a.out
0
$

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

end of thread, other threads:[~2023-11-03 10:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-31 11:13 [Bug tree-optimization/112310] New: [14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since r14-1161-g5476de2618f shaohua.li at inf dot ethz.ch
2023-10-31 12:02 ` [Bug tree-optimization/112310] " rguenth at gcc dot gnu.org
2023-10-31 12:03 ` rguenth at gcc dot gnu.org
2023-10-31 15:52 ` rguenth at gcc dot gnu.org
2023-11-03  9:40 ` rguenth at gcc dot gnu.org
2023-11-03 10:35 ` cvs-commit at gcc dot gnu.org
2023-11-03 10:35 ` 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).