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: Tue, 23 Nov 2021 08:23:03 +0000	[thread overview]
Message-ID: <bug-103278-4-nQlhS8sXf5@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
----------------------------------------------------------------------------
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot gnu.org
             Status|RESOLVED                    |NEW
         Resolution|FIXED                       |---

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
So for

rl78-elf
  if-to-switch-5

we fail the JT because it's not enabled for the target.  w/o the CD-DCE change
we build a bit-test from

;; Canonical GIMPLE case clusters: 34 39 44 46 58 59 60 62 92

which we then expand into a new switch without any bit tests(?).
After the CD-DCE change we have improved(?) clusters:

;; Canonical GIMPLE case clusters: 34 39 44 46 58-60 62 92

and thus the output is no longer(?) beneficial.

I wonder if the merging of clusters done as part of the sorting is
counter-productive since it distorts the profitability?  If we check against
the
size of the unmerged clusters like with the following the testcase
will pass again.  I also notice we don't take advantage of the
merging and create

  switch (c_3(D)) <default: <L13> [INV], case 34: <L12> [INV], case 39: <L12>
[INV], case 44: <L12> [INV], case 46: <L12> [INV], case 58: <L12> [INV], case
59: <L12> [INV], case 60: <L12> [INV], case 62: <L12> [INV], case 92: <L12>
[INV]>

instead of one 'case 58-60:'

diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc
index 16fabef7ca0..b64a1915e15 100644
--- a/gcc/gimple-if-to-switch.cc
+++ b/gcc/gimple-if-to-switch.cc
@@ -240,7 +240,7 @@ if_chain::is_beneficial ()

   vec<cluster *> output
     = jump_table_cluster::find_jump_tables (filtered_clusters);
-  bool r = output.length () < filtered_clusters.length ();
+  bool r = output.length () < clusters.length ();
   if (r)
     {
       dump_clusters (&output, "JT can be built");
@@ -251,7 +251,7 @@ if_chain::is_beneficial ()
     output.release ();

   output = bit_test_cluster::find_bit_tests (filtered_clusters);
-  r = output.length () < filtered_clusters.length ();
+  r = output.length () < clusters.length ();
   if (r)
     dump_clusters (&output, "BT can be built");


Martin, can you please look into this?

  parent reply	other threads:[~2021-11-23  8:23 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
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 [this message]
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-nQlhS8sXf5@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: link
Be 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).