public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: Jakub Jelinek <jakub@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	 Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] Add if-chain to switch conversion pass.
Date: Thu, 15 Oct 2020 14:38:42 +0200	[thread overview]
Message-ID: <CAFiYyc203LRe21ycB9M21up3yedGfBJuWAGcpDZenHVf+u_+_A@mail.gmail.com> (raw)
In-Reply-To: <d1e91d0c-785e-9281-89c7-25f15c3f1027@suse.cz>

On Mon, Oct 12, 2020 at 3:02 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 10/12/20 2:44 PM, Martin Liška wrote:
> > On 10/7/20 10:00 AM, Richard Biener wrote:
> >> As said I'd have a BB-local pass over BBs recording the index variable
> >> and the range covered by the BBs gcond, plus recording how many excess
> >> stmts there are for eventual code motion.
> >>
> >> Only after that BB-local pass start to group BBs in a walk from dominated to
> >> dominating BBs looking for common indexes and building a case vector.
> >>
> >> The main thing is to avoid repeatedly analyzing BBs conditions (so the first
> >> pass could be also a on-demand precompute thing) and making the
> >> case vector build optimal.
> >
> > I have a patch that does that using the infrastructure from tree-ssa-reassoc.
> > Now I would like to implement the code hoisting. Am I right that we want
> > something like:
> >
> > if (index == C0)
> >    goto BB_0;
> > else
> > {
> >    BB1_to_hoist_stmts;
> >    if (index == C1)
> >      goto BB_1;
> >    else
> >    {
> >      BB2_to_hoist_stmts;
> >      if (index == C2)
> >        goto BB_2;
> >      else
> >        goto default_BB;
> >    }
> > }
> >
> > be converted into:
> >
> > switch(index)
> > {
> >     case C0:
> >       goto BB_0;
> >     case C1:
> >       BB1_to_hoist_stmts;
> >       goto BB_1;
> >     case C2:
> >       BB1_to_hoist_stmts;
> >       BB2_to_hoist_stmts;
> >       goto BB_2;
> >     else:
> >       BB1_to_hoist_stmts;
> >       BB2_to_hoist_stmts;
> >       goto default_BB;
> > }
> >
> > ?
>
> Reading again Richi's comment:
>
> > ifcombine simply hoists any stmts without side-effects up the
> > dominator tree and thus only requires BBs without side-effects
> > (IIRC there's a predicate fn for that).
>
> we likely want to hoist the statements "up" to the gswitch BB?

Yes.  code sinking later will sink what can be sunk.

> Martin
>
> >
> > Thanks,
> > Martin
>

  reply	other threads:[~2020-10-15 12:38 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 14:23 Martin Liška
2019-11-04 14:49 ` Jakub Jelinek
2019-11-05 12:38   ` Richard Biener
2019-11-06 21:03     ` Bernhard Reutner-Fischer
2019-11-14  9:44       ` Martin Liška
2019-11-14 12:35         ` Bernhard Reutner-Fischer
2019-11-14  9:41     ` Martin Liška
2019-11-14 10:48       ` Richard Biener
2019-11-15 13:56         ` Martin Liška
2020-09-01 11:47           ` Martin Liška
2020-09-01 14:50             ` David Malcolm
2020-09-02 11:53               ` Martin Liška
2020-09-21  8:55                 ` Martin Liška
2020-09-24 12:41                 ` Richard Biener
2020-09-25 14:05                   ` Martin Liška
2020-09-29  8:46                     ` Richard Biener
2020-10-02 13:26                       ` Martin Liška
2020-10-02 14:19                         ` Andrew MacLeod
2020-10-06 12:09                           ` Martin Liška
2020-10-06 12:56                             ` Andrew MacLeod
2020-10-06 13:09                               ` Martin Liška
2020-10-06 13:23                                 ` Andrew MacLeod
2020-10-06 13:41                                 ` Richard Biener
2020-10-02 13:23                   ` Martin Liška
2020-10-06  7:47                     ` Richard Biener
2020-10-06 13:48                       ` Martin Liška
2020-10-06 14:12                         ` Jakub Jelinek
2020-10-12 12:39                           ` Martin Liška
2020-10-12 13:00                             ` Jakub Jelinek
2020-10-14 18:09                             ` Andrew MacLeod
2020-10-07  8:00                         ` Richard Biener
2020-10-12 12:44                           ` Martin Liška
2020-10-12 13:01                             ` Martin Liška
2020-10-15 12:38                               ` Richard Biener [this message]
2020-10-16 14:04                             ` [PATCH v2] " Martin Liška
2020-11-06 12:31                               ` Richard Biener
2020-11-09 12:26                                 ` Martin Liška
2020-11-16 12:21                                   ` Richard Biener
2020-11-18 12:25                                     ` Martin Liška
2020-11-19 14:46                                       ` Richard Biener
2020-11-20  8:57                                         ` Martin Liška
2020-11-20 14:37                                           ` Richard Biener
2020-11-27 15:07                                             ` Martin Liška
2020-12-01 10:34                                               ` Richard Biener
2020-12-01 13:57                                                 ` [PATCH] if-to-switch: Support chain with 2 BBs Martin Liška
2020-12-01 22:14                                                   ` Jeff Law
2019-11-13 11:32   ` [PATCH] Add if-chain to switch conversion pass Martin Liška
2019-11-13 16:14     ` Michael Matz
2019-11-14 10:07       ` Martin Liška

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=CAFiYyc203LRe21ycB9M21up3yedGfBJuWAGcpDZenHVf+u_+_A@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jakub@redhat.com \
    --cc=mliska@suse.cz \
    /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).