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/113756] New: Wrong code at -O2 on x86_64-linux-gnu since r14-2780-g39f117d6c87
Date: Sun, 04 Feb 2024 14:14:50 +0000	[thread overview]
Message-ID: <bug-113756-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113756
           Summary: Wrong code at -O2 on x86_64-linux-gnu since
                    r14-2780-g39f117d6c87
           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: aldyh at redhat dot com
  Target Milestone: ---

gcc at -O2 produced the wrong code.

Bisected to r14-2780-g39f117d6c87

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

% cat reduced.c
int printf(const char *, ...);
int d, e, i, k, l = -8;
char h, j;
int m(int n, int o, int p3) {
  int a = o - p3, b = n - p3, c = a + b, f = -b, g = c < 0 ? -c : c;
  return a <= f && a <= g ? o : p3;
}
void q(int *n, unsigned short o) {
  unsigned p = 8896;
  for (; e >= 0; e--)
    p = 5377;
  for (; h <= 0; h++)
    for (; j <= 0; j++) {
      *n = 1611581749;
      i = m(34, p - 5294, *n - 1611581687);
      k = i + p + 65535 + o + *n - 1611718251;
      printf("%d\n", k);
    }
}
int main() {
  q(&l, l);
}
%
% gcc -O0 reduced.c &&./a.out
0
% gcc -O2 reduced.c &&./a.out
21
%

             reply	other threads:[~2024-02-04 14:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-04 14:14 shaohua.li at inf dot ethz.ch [this message]
2024-02-04 18:13 ` [Bug tree-optimization/113756] " pinskia at gcc dot gnu.org
2024-02-04 18:17 ` pinskia at gcc dot gnu.org
2024-02-05  9:04 ` [Bug tree-optimization/113756] [14 regression] " rguenth at gcc dot gnu.org
2024-02-06 15:59 ` jakub at gcc dot gnu.org
2024-02-06 16:05 ` jakub at gcc dot gnu.org
2024-02-07  9:59 ` cvs-commit at gcc dot gnu.org
2024-02-07 10:00 ` jakub 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-113756-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).