public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111167] New: swapping around duplicated conditionals can produce better code Date: Sat, 26 Aug 2023 19:39:51 +0000 [thread overview] Message-ID: <bug-111167-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111167 Bug ID: 111167 Summary: swapping around duplicated conditionals can produce better code Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take reduced from GCC's sources for lookup_attribute: ``` void f(int); inline void canonicalize_attr_name(const char *&s, int l) { if (l > 4 && s[0] == '_' && s[l - 1] == '_' ) s += 2; } void lookup_attribute(const char *attr_ns, int list, int t) { if (attr_ns && attr_ns[0] != '_') { canonicalize_attr_name(attr_ns, 5); } if (list == 0) { short attr_ns_len = attr_ns ? t : 0; f(attr_ns_len); } } ``` In optimized we have: ``` if (attr_ns_25(D) != 0B) goto <bb 4>; [70.00%] else goto <bb 3>; [30.00%] <bb 3> [local count: 322122543]: if (list_10(D) == 0) goto <bb 6>; [50.00%] else goto <bb 7>; [50.00%] <bb 4> [local count: 751619279]: if (list_10(D) == 0) goto <bb 5>; [50.00%] else goto <bb 7>; [50.00%] ``` But we should really just have: if (list_10(D) == 0) goto bb7; if (attr_ns_25(D) != 0B) goto bb5; else bb6;
next reply other threads:[~2023-08-26 19:39 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-08-26 19:39 pinskia at gcc dot gnu.org [this message] 2023-08-26 19:39 ` [Bug tree-optimization/111167] " pinskia at gcc dot gnu.org 2023-08-26 19:55 ` pinskia at gcc dot gnu.org 2023-08-27 23:34 ` pinskia at gcc dot gnu.org
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-111167-4@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).