public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zhendong.su at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107523] New: wrong code at -O2 and -O3 on x86_64-linux-gnu
Date: Fri, 04 Nov 2022 07:25:45 +0000	[thread overview]
Message-ID: <bug-107523-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107523
           Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as 12.2 compiles the test correctly.

Compiler Explorer: https://godbolt.org/z/1erPMzzjK

[522] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221104 (experimental) [master r13-3645-gfabe470b244] (GCC) 
[523] % 
[523] % gcctk -Os small.c; ./a.out
[524] % 
[524] % gcctk -O2 small.c
[525] % ./a.out
Floating point exception
[526] % 
[526] % cat small.c
int a, b = 1;
unsigned int c = 1;
int main() {
  int d = 1, f;
  if (b)
    d = 0;
  a = -1;
  b = ~d ^ 465984011;
 L1:;
  if (b < 2)
    f = b;
  b = f;
  if (f <= a) {
    int g = -(a && 1), h = g - f && a, i = ~(c / f) && 1 % (a | h);
    if (c) {
      g = f;
      if (i || (g && (g > -465984012)))
        goto L2;
    }
    c = g | f / c;
  }
  if (0)
  L2:
    a = 0;
  if (a <= c)
    goto L1;
  return 0;
}

             reply	other threads:[~2022-11-04  7:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  7:25 zhendong.su at inf dot ethz.ch [this message]
2022-11-04 19:45 ` [Bug tree-optimization/107523] [13 Regression] " pinskia at gcc dot gnu.org
2022-11-10 15:39 ` [Bug tree-optimization/107523] [13 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu since r13-3628-g6fd485d15c1a2c42 marxin at gcc dot gnu.org
2022-11-11 19:48 ` cvs-commit at gcc dot gnu.org
2022-11-11 19:54 ` amacleod at redhat dot com

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-107523-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).