public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zhaohaifeng4 at huawei 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: Tue, 04 Jun 2024 01:38:39 +0000	[thread overview]
Message-ID: <bug-114532-4-A0YlpKPha7@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

Zhaohaifeng <zhaohaifeng4 at huawei dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zhaohaifeng4 at huawei dot com

--- Comment #2 from Zhaohaifeng <zhaohaifeng4 at huawei dot com> ---
(In reply to Andrew Pinski from comment #1)
> ```
> Rec_Pointer     Ptr_Glob,
>                 Next_Ptr_Glob;
> int             Int_Glob;
> Boolean         Bool_Glob;
> char            Ch_1_Glob,
>                 Ch_2_Glob;
> int             Arr_1_Glob [50];
> int             Arr_2_Glob [50] [50];
> ```
> 
> Maybe the order of these changed in the layout of the final executable.
> In the case of -fcommon, the layout of these are handled by the linker while
> with -fno-common, they are handled by compiler into the assembly into the
> specific section (and then the sections are combined/laid out by the linker).
> 
> So maybe look at the linker map and compare it to what GCC does with
> -fno-common in the .s file.

Some test results:
1. Using gcc 10.3 the variables are arranged from the last Dhrystone_Per_Second
to the first Ptr_Glob, both in .s file and the final binary. If we change the
sequence of the variables in the source code, the sequence in assembly and
binary is also changed as in source code.

2. Using gcc 8.5 the variables are arranged specially both in assembly and
final binary,If the variable sequence is changed in the source code, the
sequence in assembly and binary is NOT changed.

Do we expect the fcommon option do some performance optimizatin? How does
fcommon arrange the variables?

  parent reply	other threads:[~2024-06-04  1:38 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 [this message]
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
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-A0YlpKPha7@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: link
Be 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).