public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108751] Removing dead code results in worse generated target code at -Os Date: Fri, 10 Feb 2023 17:03:49 +0000 [thread overview] Message-ID: <bug-108751-4-1evVnuK8RV@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108751-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108751 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The code isn't smaller, which indeed for -Os is important, though many GIMPLE decisions need to be done just from heuristics whether a particular transformation typically results in smaller or larger code, because the sizes can't be compared until much later, just estimated. What happens in this testcase is that b is determined to be constant only during IPA optimizations, ccp2 after IPA then propagates the value of 1 into b users and before lim2 we have pretty much the same IL (if I rename ssa name versions and temporary suffixes), the only difference of between one where b has been discovered constant 1 after IPA and where it has been determined 1 earlier is in the counts and branch probabilities: - <bb 2> [local count: 1018865821]: + <bb 2> [local count: 536870913]: goto <bb 5>; [100.00%] - <bb 3> [local count: 54876003]: + <bb 3> [local count: 536870911]: return 3; - <bb 4> [local count: 460874625]: + <bb 4> [local count: 264428955]: _2 = a.2_3 + 1; a = _2; - <bb 5> [local count: 997745539]: + <bb 5> [local count: 801299868]: a.2_3 = a; if (a.2_3 != 0) - goto <bb 4>; [94.50%] + goto <bb 4>; [33.00%] else - goto <bb 3>; [5.50%] + goto <bb 3>; [67.00%] Later on, lim2 decides to perform invariant motion in the latter case and not in the former based on the probabilities. In the first assembly movl %eax, a(%rip) is done in an inner loop, while in the latter case it is done only after the loop finishes.
prev parent reply other threads:[~2023-02-10 17:03 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-10 10:25 [Bug tree-optimization/108751] New: Removing dead code results in worse optimization " theodort at inf dot ethz.ch 2023-02-10 10:29 ` [Bug tree-optimization/108751] Removing dead code results in worse generated target code " theodort at inf dot ethz.ch 2023-02-10 17:03 ` jakub at gcc dot gnu.org [this message]
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-108751-4-1evVnuK8RV@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).