From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 584A8398B42E; Fri, 9 Apr 2021 11:39:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 584A8398B42E From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination Date: Fri, 09 Apr 2021 11:39:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: unknown X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 11:39:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99862 --- Comment #6 from Richard Biener --- (In reply to Zhendong Su from comment #1) > [578] % gcctk -O1 -S -o O1.s small.c > [579] % gcctk -O3 -S -o O3.s small.c > [580] %=20 > [580] % wc O1.s O3.s > 22 43 410 O1.s > 37 77 682 O3.s > 59 120 1092 total > [581] %=20 > [581] % grep foo O1.s > [582] % grep foo O3.s > call foo > [583] %=20 > [583] % cat small.c > extern void foo(void); > static int a, b; > static void c() { > if (a) { > foo(); > for (; b < 1; b++) > ; > } > } > int main() { > c(); > c(); > return 0; > } This is another case of failing to elide a no longer called function. We end up partially inlining c() at -O3, inlining the if (a) head and thus we eliminate the calls to c() in main rather than the call to foo in c(). I'd say the -O3 result is superior but still we fail to remove the c.part() function definition from the assembly. We have duplicates for this case.=