From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A022A3BF90E5; Tue, 4 Jun 2024 01:38:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A022A3BF90E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1717465120; bh=wrzGZL89T1hKSl+Abr5Ekr9ho4xd7yq7nGpAiRrtXSw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iuey8V7GSqZTnP7aq8YZ+88HFssy2eQliF+1apMLHYtgXP5q3qjPqLJ+Xzr9N227G 0IDDMZDNgdfE5fvR8KC0Sji6fDViTSSHelQbnRk9pNvLlC39lXbRqvkLVGaShcmQBO sCmXU4+YpHDrjLZEvCsPzoZnkVUO4cVndmQ6Amds= From: "zhaohaifeng4 at huawei dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: zhaohaifeng4 at huawei dot com X-Bugzilla-Status: WAITING 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: cc Message-ID: In-Reply-To: References: 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=3D114532 Zhaohaifeng changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zhaohaifeng4 at huawei dot= com --- Comment #2 from Zhaohaifeng --- (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]; > ``` >=20 > 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 wh= ile > 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 link= er). >=20 > 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_Se= cond to the first Ptr_Glob, both in .s file and the final binary. If we change t= he 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?=