From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2662D3858D39; Sun, 14 Nov 2021 17:38:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2662D3858D39 From: "haoxintu at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: haoxintu at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Nov 2021 17:38:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103237 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 #include struct S0 { uint16_t a; }; union U1 { struct S0 b; }; int32_t g1[1] =3D {0}; uint32_t g2[][10][1] =3D { {}, {}, {}, {}, {}, {}, {{}, {}, {}, {}, {}, {}, {4294967295UL}}}; union U1 g3; static int32_t func_1() { int32_t *l_1 =3D &g1[0]; uint32_t l_2 ; for (g3.b.a =3D (27); (g3.b.a !=3D 45); g3.b.a =3D g3.b.a + 9) { for (l_2 =3D 0; (l_2 <=3D 3); l_2 +=3D 1) { uint32_t *l_3 =3D &g2[6][6][0]; *l_1 =3D *l_3 ^=3D ((0 =3D=3D 0) << 0); } } return 0; } int main() { func_1(); for (int i =3D 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=3Dgcc COLLECT_LTO_WRAPPER=3D/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=3D/home/haoxin/haoxin-data/compilers/gcc/build/ --enable-bootstrap --enable-checking=3Drelease --enable-multilib --enable-languages=3Dc,c++,lto --no-create --no-recursion Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20211114 (experimental) (GCC)=20 Can also check here: https://godbolt.org/z/ncar1aWYM Thanks, Haoxin=