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/103237] New: wrong code with -ftree-vectorize at -O1 on x86_64-linux-gnu
Date: Sun, 14 Nov 2021 17:38:10 +0000	[thread overview]
Message-ID: <bug-103237-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103237
           Summary: wrong code with -ftree-vectorize 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.

This seems a long latent bug existed after GCC-10.1.

$cat small.c
#include <stdint.h>
#include <stdio.h>
struct S0 {
  uint16_t a;
};
union U1 {
  struct S0 b;
};
int32_t g1[1] = {0};
uint32_t g2[][10][1] = {
    {}, {}, {}, {}, {}, {}, {{}, {}, {}, {}, {}, {}, {4294967295UL}}};
union U1 g3;
static int32_t func_1() {
  int32_t *l_1 = &g1[0];
  uint32_t l_2 ;
  for (g3.b.a = (27); (g3.b.a != 45);
       g3.b.a = g3.b.a + 9) {
    for (l_2 = 0; (l_2 <= 3); l_2 += 1) {
      uint32_t *l_3 = &g2[6][6][0];
      *l_1 = *l_3 ^= ((0 == 0) << 0);
    }
  }
  return 0;
}
int main() {
  func_1();
  for (int i = 0; i < 1; i++)
    printf("%d\n", g1[i]);
  return 0;
}


$gcc -O2 -ftree-vectorize small.c ; ./a.out
-1

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

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

$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-multilib --enable-languages=c,c++,lto
--no-create --no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211114 (experimental) (GCC) 

Can also check here: https://godbolt.org/z/ncar1aWYM

Thanks,
Haoxin

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

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-14 17:38 haoxintu at gmail dot com [this message]
2021-11-14 21:09 ` [Bug tree-optimization/103237] [10/11/12 Regression] " pinskia at gcc dot gnu.org
2021-11-15  8:37 ` [Bug tree-optimization/103237] [10/11/12 Regression] wrong code with -ftree-vectorize at -O1 on x86_64-linux-gnu since r10-1361-g9f962469cabc7fdc marxin at gcc dot gnu.org
2021-11-15  9:19 ` rguenth at gcc dot gnu.org
2021-11-15  9:50 ` rguenth at gcc dot gnu.org
2021-11-15  9:55 ` rguenth at gcc dot gnu.org
2021-11-15 10:00 ` [Bug tree-optimization/103237] [10/11/12 Regression] wrong code with -ftree-vectorize at -O1 on x86_64-linux-gnu marxin at gcc dot gnu.org
2021-11-15 10:34 ` [Bug tree-optimization/103237] [10/11/12 Regression] wrong code with -ftree-vectorize at -O1 on x86_64-linux-gnu starting with r7-1219-gb28ead45fe630b9e rguenth at gcc dot gnu.org
2021-11-15 12:08 ` cvs-commit at gcc dot gnu.org
2021-11-22  8:00 ` [Bug tree-optimization/103237] [9/10/11 " cvs-commit at gcc dot gnu.org
2022-02-17 10:48 ` [Bug tree-optimization/103237] [9/10 " cvs-commit at gcc dot gnu.org
2022-02-17 11:56 ` [Bug tree-optimization/103237] [9 " cvs-commit at gcc dot gnu.org
2022-02-17 11:57 ` 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-103237-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).