public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "haoxintu at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/103209] New: [12 Regression] wrong code at -O1 on x86_64-linux-gnu
Date: Fri, 12 Nov 2021 12:17:28 +0000	[thread overview]
Message-ID: <bug-103209-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103209
           Summary: [12 Regression] wrong code at -O1 on x86_64-linux-gnu
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi all.

It seems to be a recent regression issue.

$cat small.c
#include <stdio.h>
#include <stdint.h>

int32_t a[6];
int64_t b;
int32_t *c;
int32_t **d = &c;
int64_t *e = &b;
int32_t **const *f = &d;
int32_t **const **g = &f;
int32_t *h();
static int16_t j();
static uint32_t k(int8_t, const int32_t *, int64_t);
static uint32_t l() {
  int32_t *m = &a[3];
  int32_t n = 0;
  int8_t o = 0;
  int32_t *p[] = {&n, &n, &n, &n};
  uint32_t q[6][1][2] = {};
  for (o = 0; o <= 1; o = 6)
    if (h(j(k(3, 0, q[2][0][0]), &n), n) == p[3])
      *m = *e;
  return 0;
}
int32_t *h(uint32_t, int32_t) { return ***g; }
int16_t j(uint32_t, int32_t *r) { **f = r; }
uint32_t k(int8_t, const int32_t *, int64_t) { *e = 3; return 0;}
int main() {
  int i = 0;
  l();
  for (i = 0; i < 6; i++){
    if (i == 3)
        printf("%d\n", a[i]);
  }
  return 0;
}

$gcc -O1 small.c ; ./a.out
0

$gcc -O0 small.c ; ./a.out
3

$gcc -O2 small.c ; ./a.out
3

$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/haoxin/haoxin-data/compilers/gcc/build/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:../configure
--prefix=/home/haoxin/haoxin-data/compilers/gcc/build/ --enable-bootstrap
--enable-checking=release --enable-languages=c,c++ --enable-multilib :
(reconfigured) ../configure
--prefix=/home/haoxin/haoxin-data/compilers/gcc/build/ --enable-bootstrap
--enable-checking=release --enable-multilib --enable-languages=c,c++,lto
--no-create --no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211112 (experimental) (GCC) 

Thanks,
Haoxin

             reply	other threads:[~2021-11-12 12:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 12:17 haoxintu at gmail dot com [this message]
2021-11-12 13:13 ` [Bug tree-optimization/103209] [12 Regression] wrong code at -O1 on x86_64-linux-gnu since r12-4324-g008e7397dad971c0 marxin at gcc dot gnu.org
2021-11-12 13:17 ` rguenth at gcc dot gnu.org
2021-11-12 13:51 ` hubicka at gcc dot gnu.org
2021-11-12 20:55 ` hubicka at gcc dot gnu.org
2021-11-12 21:03 ` marxin at gcc dot gnu.org
2021-11-12 22:56 ` cvs-commit at gcc dot gnu.org
2021-11-12 22:58 ` hubicka 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-103209-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).