public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "shaohua.li at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/112310] New: [14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since r14-1161-g5476de2618f
Date: Tue, 31 Oct 2023 11:13:33 +0000	[thread overview]
Message-ID: <bug-112310-4@http.gcc.gnu.org/bugzilla/> (raw)

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
$

             reply	other threads:[~2023-10-31 11:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 11:13 shaohua.li at inf dot ethz.ch [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112310-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).