public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "shaohua.li at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110738] New: GCC trunk failed to do some optimizations since GCC-8 Date: Wed, 19 Jul 2023 09:03:45 +0000 [thread overview] Message-ID: <bug-110738-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110738 Bug ID: 110738 Summary: GCC trunk failed to do some optimizations since GCC-8 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch Target Milestone: --- For the following test case, gcc trunk at -O3 emits a relatively large assembly code since GCC-8. Clang can remove all the code. Compiler explorer: https://godbolt.org/z/hzf8Pr484 The test case is adapted from an official GCC test case: https://github.com/gcc-mirror/gcc/blob/ae862e0e47cb2d62d7c624ab999a3bd8bd2914ef/gcc/testsuite/gcc.dg/strncmp-3.c I only changed `int neg=0` to `int neg=1`. $ gcc-tk -O3 -S -o trunk.s a.c $ gcc-7.4 -O3 -S -o old.s a.c $ wc trunk.s old.s 217 654 5999 trunk.s 11 19 175 old.s 228 673 6174 total $ $ cat a.c #define AB_D "ab\0d" #define ABCDEF_H "abcdef\0h" #define ABCDEFGHIJKLMN_P "abcdefghijklmn\0p" char ab_d[] = AB_D; char abcdef_h[] = ABCDEF_H; extern int strncmp (const char*, const char*, __SIZE_TYPE__); __attribute__((noipa)) void sink (const void *p, ...) { (void)&p; } #define strncmp(a, b, n) (sink (a, b), strncmp (a, b, n)) int main (void) { int zero = 0; zero += strncmp (ab_d, AB_D,1); zero += strncmp (ab_d, AB_D,2); zero += strncmp (ab_d, AB_D,3); zero += strncmp (ab_d, AB_D,4); zero += strncmp (ab_d, AB_D,5); zero += strncmp (ab_d, ABCDEF_H,1); zero += strncmp (ab_d, ABCDEF_H,2); zero += strncmp (abcdef_h, AB_D,2); zero += strncmp (abcdef_h, ABCDEF_H,2); zero += strncmp (abcdef_h, ABCDEF_H,3); zero += strncmp (abcdef_h, ABCDEF_H,4); zero += strncmp (abcdef_h, ABCDEF_H,5); zero += strncmp (abcdef_h, ABCDEF_H,6); zero += strncmp (abcdef_h, ABCDEF_H,7); zero += strncmp (abcdef_h, ABCDEF_H,8); zero += strncmp (abcdef_h, ABCDEF_H,9); if (zero != 0) __builtin_abort (); int neg = 1; neg -= strncmp (ab_d, ABCDEF_H,3) <0; neg -= strncmp (ab_d, ABCDEF_H,4) <0; neg -= strncmp (ab_d, ABCDEF_H,5) <0; neg -= strncmp (ab_d, ABCDEF_H,6) <0; neg -= strncmp (ab_d, ABCDEF_H,7) <0; neg -= strncmp (ab_d, ABCDEF_H,8) <0; neg -= strncmp (ab_d, ABCDEF_H,9) <0; if (neg !=-7){ __builtin_abort (); } } $ $ gcc-tk -v Using built-in specs. COLLECT_GCC=gcc-tk COLLECT_LTO_WRAPPER=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-ec842611618c9f8a50f3326d42c51961de8b28a5/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-multilib --disable-bootstrap --enable-languages=c,c++ --prefix=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-ec842611618c9f8a50f3326d42c51961de8b28a5 Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230719 (experimental) (GCC) $
next reply other threads:[~2023-07-19 9:03 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-19 9:03 shaohua.li at inf dot ethz.ch [this message] 2023-07-19 9:08 ` [Bug c/110738] " pinskia at gcc dot gnu.org 2023-07-19 9:10 ` pinskia at gcc dot gnu.org 2023-07-19 9:16 ` shaohua.li at inf dot ethz.ch 2023-07-19 11:18 ` xry111 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-110738-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).