public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "david at westcontrol dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/114532] gcc -fno-common option causes performance degradation on certain architectures Date: Wed, 05 Jun 2024 08:24:50 +0000 [thread overview] Message-ID: <bug-114532-4-oqymtENkXN@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-114532-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114532 --- Comment #7 from David Brown <david at westcontrol dot com> --- (In reply to Xi Ruoyao from comment #6) > (In reply to Zhaohaifeng from comment #5) > > > Does gcc implement -fsection-anchors like function in -fcommon option for > > x86? In general concept, gcc should has some similar feature for x86 and ARM. > AFAIK, -fsection-anchors and -fcommon / -fno-common are completely independent. But section anchors cannot work with "common" symbols, no matter what architecture, because at compile time the compiler does not know the order of allocation of the common symbols. It /does/ know the order of allocation of symbols defined in the current translation unit, such as initialised data, -fno-common zero initialised data, and static data. This information can be used with section anchors and also with other optimisations based on the relative positions of objects. > AFAIK it's not very useful for CISC architectures supporting variable-length > fancy memory operands. That seems strange to me. But I know very little about how targets such as x86-64 work for global data that might be complicated with load-time or run-time linking - my experience and understanding is all with statically linked binaries. It seems, from my brief testing, that for the x86-64 target, the compiler does not do any optimisations based on the relative positions of data defined in a unit (whether initialised, non-common bss, or static). For targets such as the ARM, gcc can optimise as though the individual variables were fields in a struct where it knows the relative positions. I don't see any reason why x86-64 should not benefit from some of these, though I realise that scheduling and out-of-order execution will mean some apparent optimisations would be counter-productive. Maybe there is some kind of address space layout randomisation that is playing a role here? Anyway, I cannot see any reason while -fno-common should result in the slower run-times the OP saw (though I have only looked at current gcc versions). I haven't seen any differences in the code generated for -fcommon and -fno-common on the x86-64. And my experience on other targets is that -fcommon allows optimisations that cannot be done with -fno-common, thus giving faster code. I have not, however, seen the OP's real code - I've just made small tests.
next prev parent reply other threads:[~2024-06-05 8:24 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-30 9:47 [Bug c/114532] New: " h13958451065 at 163 dot com 2024-03-30 18:48 ` [Bug middle-end/114532] " pinskia at gcc dot gnu.org 2024-06-04 1:38 ` zhaohaifeng4 at huawei dot com 2024-06-04 1:41 ` sjames at gcc dot gnu.org 2024-06-04 11:19 ` david at westcontrol dot com 2024-06-05 4:12 ` zhaohaifeng4 at huawei dot com 2024-06-05 5:46 ` xry111 at gcc dot gnu.org 2024-06-05 8:24 ` david at westcontrol dot com [this message] 2024-06-05 8:46 ` zhaohaifeng4 at huawei dot com 2024-06-05 9:26 ` xry111 at gcc dot gnu.org 2024-06-05 9:29 ` xry111 at gcc dot gnu.org 2024-06-05 9:30 ` david at westcontrol dot com
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-114532-4-oqymtENkXN@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).