public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103237] New: wrong code with -ftree-vectorize at -O1 on x86_64-linux-gnu
@ 2021-11-14 17:38 haoxintu at gmail dot com
  2021-11-14 21:09 ` [Bug tree-optimization/103237] [10/11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: haoxintu at gmail dot com @ 2021-11-14 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-02-17 11:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-14 17:38 [Bug tree-optimization/103237] New: wrong code with -ftree-vectorize at -O1 on x86_64-linux-gnu haoxintu at gmail dot com
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

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