From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BFFCA3858D39; Fri, 30 Jun 2023 05:12:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFFCA3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688101935; bh=CwPmhPx8OTmc8ZfFSfoaUiuS5QeDbigcSe2a2YJ5Woo=; h=From:To:Subject:Date:From; b=sjdHSx+VG430EdDtzByeHPJGDZ1v6PrW1L3uCvWJ8Ib7U2serJ56ME2Cz+yGXXn8m meX2mMvoZ+U7nQmmMVI0/1TORvgytMB0MP44yrD2UAlWhirRbrVRdjr8S1Zaz5cBmk vhkDR5yatjVJG5pRA16NcJ7dWcS0jqUXm82RP8LE= From: "jwzeng at nuaa dot edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110494] New: [14 Regression] Wrong code at -O3 on x86_64-pc-linux-gnu Date: Fri, 30 Jun 2023 05:12:15 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jwzeng at nuaa dot edu.cn 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110494 Bug ID: 110494 Summary: [14 Regression] Wrong code at -O3 on x86_64-pc-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jwzeng at nuaa dot edu.cn Target Milestone: --- Link to the Compiler Explorer: https://godbolt.org/z/dq38c9zea The following code snippet: #include unsigned long long int seed =3D 0; unsigned int var_1 =3D 631366671U; #define min(a, b) ((a) < (b) ? (a) : (b)) int main() { short a[18]; int b =3D 1; unsigned long long int c[18]; unsigned long long int d[18]; for (int i =3D 0; i < 18; ++i) a[i] =3D 4, c[i] =3D 3, d[i] =3D 2; for (unsigned short i =3D 1; i < 16; i +=3D var_1 - 57737) a[i] =3D (short)min(b % (~var_1), c[i] ? d[i] : (long long unsigned int)b); for (int i =3D 0; i < 18; ++i) seed ^=3D a[i]; printf("%llu\n", seed); } > $ /usr/gcc-trunk/bin/gcc -O0 bug.c; ./a.out > 5 > $ /usr/gcc-trunk/bin/gcc -O1 bug.c; ./a.out > 5 > $ /usr/gcc-trunk/bin/gcc -O2 bug.c; ./a.out > 5 > $ /usr/gcc-trunk/bin/gcc -O3 bug.c; ./a.out > 7 > $ /usr/gcc-trunk/bin/gcc -Os bug.c; ./a.out > 5 When compiled with -O3, it prints the wrong result 7 instead of 5. Earlier = GCCs do not have this bug. > $ /usr/gcc-trunk/bin/gcc --version Using built-in specs. COLLECT_GCC=3D/home/compilers/gcc/gcc-trunk/bin/gcc COLLECT_LTO_WRAPPER=3D/home/compilers/gcc/gcc-trunk/bin/../libexec/gcc/x86_= 64-pc-linux-gnu/14.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk-source/gcc/configure --enable-languages=3Dc,c++,fortran --enable-checking=3Drelease --enable-valgrind-annotations --disable-werror --disable-libstdcxx-pch --enable-libgomp --enable-lto --enable-gold --with-plugin-ld=3Dgold --prefix=3D/usr/local/gcc-trunk Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230619 (experimental) [master r14-1917-gf8e0270272] (G= CC)=