public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103278] [12 Regression] Recent change to cddce inhibits switch optimization Date: Thu, 18 Nov 2021 08:48:04 +0000 [thread overview] Message-ID: <bug-103278-4-esQyZzOUJC@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103278-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103278 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marxin at gcc dot gnu.org --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- So the main issue is that while CD-DCE tries to undo the factorization by running cleanup CFG, this process has the choice between two forwarder blocks to remove - one pre-existing to disambiguate the two edges from the last test into the PHI and the one we created. But CFG cleanup simply picks the first candidate which, in some cases is not the newly created one. That results in different handling of if-to-switch cluster processing. In particular the ->m_has_forward_bb handling seems important. If we do diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc index 16fabef7ca0..157c5f6f10b 100644 --- a/gcc/gimple-if-to-switch.cc +++ b/gcc/gimple-if-to-switch.cc @@ -219,8 +219,7 @@ if_chain::is_beneficial () { simple_cluster *right = static_cast<simple_cluster *> (clusters[i]); tree type = TREE_TYPE (left->get_low ()); - if (!left->m_has_forward_bb - && !right->m_has_forward_bb + if (left->m_has_forward_bb == right->m_has_forward_bb && left->m_case_bb == right->m_case_bb) { if (wi::eq_p (wi::to_wide (right->get_low ()) - wi::to_wide which seems more natural then even with the original IL we don't get any if-to-switch as we seem to fail JT building because the number of clusters is then just 4 which is lower than case_values_threshold () which is 5. If we supply --param case-values-threshold=4 to the testcase it is optimized (that overrides the target default) with the result switch (aChar_10(D)) <default: <L7> [INV], case 9 ... 10: <L6> [INV], case 12: <L6> [INV], case 13: <L6> [INV], case 32: <L6> [INV], case 48: <L6> [INV]> <bb 3> : <L6>: <bb 4> : # iftmp.0_9 = PHI <1(3), 0(2)> <L7>: return iftmp.0_9; compared to the following before the CD-DCE change which looks clearly worse (but even the above has unmerged case 12 and 13?!) switch (aChar_10(D)) <default: <L10> [INV], case 9 ... 10: <L6> [INV], case 12: <L6> [INV], case 13: <L7> [INV], case 32: <L7> [INV], case 48: <L8> [INV]> <bb 3> : <L6>: goto <bb 6>; [100.00%] <bb 4> : <L7>: goto <bb 6>; [100.00%] <bb 5> : <L8>: <bb 6> : # iftmp.0_9 = PHI <1(4), 0(2), 1(3), 1(5)> <L10>: return iftmp.0_9; so this looks like a testcase issue to me.
next prev parent reply other threads:[~2021-11-18 8:48 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-16 17:16 [Bug tree-optimization/103278] New: " law at gcc dot gnu.org 2021-11-16 23:25 ` [Bug tree-optimization/103278] " pinskia at gcc dot gnu.org 2021-11-16 23:29 ` pinskia at gcc dot gnu.org 2021-11-17 14:48 ` law at gcc dot gnu.org 2021-11-18 7:36 ` rguenth at gcc dot gnu.org 2021-11-18 8:48 ` rguenth at gcc dot gnu.org [this message] 2021-11-18 9:02 ` cvs-commit at gcc dot gnu.org 2021-11-18 9:04 ` rguenth at gcc dot gnu.org 2021-11-23 3:31 ` law at gcc dot gnu.org 2021-11-23 8:23 ` rguenth at gcc dot gnu.org 2021-11-23 8:25 ` marxin at gcc dot gnu.org 2021-11-29 15:23 ` marxin at gcc dot gnu.org 2021-11-30 7:22 ` rguenther at suse dot de 2021-11-30 13:48 ` cvs-commit at gcc dot gnu.org 2021-11-30 13:48 ` marxin 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-103278-4-esQyZzOUJC@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).