public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jwzeng at nuaa dot edu.cn" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-110494-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110494 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 <stdio.h> unsigned long long int seed = 0; unsigned int var_1 = 631366671U; #define min(a, b) ((a) < (b) ? (a) : (b)) int main() { short a[18]; int b = 1; unsigned long long int c[18]; unsigned long long int d[18]; for (int i = 0; i < 18; ++i) a[i] = 4, c[i] = 3, d[i] = 2; for (unsigned short i = 1; i < 16; i += var_1 - 57737) a[i] = (short)min(b % (~var_1), c[i] ? d[i] : (long long unsigned int)b); for (int i = 0; i < 18; ++i) seed ^= 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=/home/compilers/gcc/gcc-trunk/bin/gcc COLLECT_LTO_WRAPPER=/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=c,c++,fortran --enable-checking=release --enable-valgrind-annotations --disable-werror --disable-libstdcxx-pch --enable-libgomp --enable-lto --enable-gold --with-plugin-ld=gold --prefix=/usr/local/gcc-trunk Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230619 (experimental) [master r14-1917-gf8e0270272] (GCC)
next reply other threads:[~2023-06-30 5:12 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-30 5:12 jwzeng at nuaa dot edu.cn [this message] 2023-06-30 5:18 ` [Bug tree-optimization/110494] " pinskia 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-110494-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: linkBe 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).