public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "Martin Liška" <mliska@suse.cz>,
	"GCC Patches" <gcc-patches@gcc.gnu.org>,
	kazu@gcc.gnu.org, "Jan Hubicka" <hubicka@ucw.cz>
Subject: Re: [PATCH] Add if-chain to switch conversion pass.
Date: Tue, 05 Nov 2019 12:38:00 -0000	[thread overview]
Message-ID: <CAFiYyc0j3uYK9Z5LVtcoG0r9PhXB=Pj5kTy6vU0XzV7H=edO2A@mail.gmail.com> (raw)
In-Reply-To: <20191104144851.GJ4650@tucnak>

On Mon, Nov 4, 2019 at 3:49 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, Nov 04, 2019 at 03:23:20PM +0100, Martin Liška wrote:
> > The patch adds a new pass that identifies a series of if-elseif
> > statements and transform then into a GIMPLE switch (if possible).
> > The pass runs right after tree-ssa pass and I decided to implement
> > matching of various forms that are introduced by folder (fold_range_test):
>
> Not a review, just a few questions:

Likewise - please do not name switches -ftree-*, 'tree' doens't add anything
but confusion to users.  Thus use -fif-to-switch or -fconvert-if-to-switch

+The transformation can help to produce a faster code for
+the switch statement.

produce faster code.

Doesn't it also produce smaller code eventually?

Please to not put code transform passes into build_ssa_passes (why did
you choose this place)?  The pass should go into pass_all_early_optimizations
instead, and I'm quite sure you want to run _after_ CSE.  I'd even say
that the pass should run as part of switch-conversion, so we build
a representation of a switch internally and then code-generate the optimal
form directly.  For now just put the pass before switch-conversion.

There are functions without comments in the patch and you copied
from DSE which shows in confusing comments left over from the original.

+  mark_virtual_operands_for_renaming (cfun);

if you did nothing renaming all vops is expensive.

I'm missing an overall comment - you are using a dominator walk
but do nothing in the after hook which means you are not really
gathering any data?  You're also setting visited bits on BBs which
means you are visiting alternate BBs during the DOM walk.

> 1) what does it do if __builtin_expect* has been used, does it preserve
>    the probabilities and if in the end decides to expand as ifs, are those
>    probabilities retained through it?
> 2) for the reassoc-*.c testcases, do you get identical or better code
>    with the patch?
> 3) shouldn't it be gimple-if-to-switch.c instead?
> 4) what code size effect does the patch have say on cc1plus (if you don't
>    count the code changes of the patch itself, i.e. revert the patch in the
>    stage3 and rebuild just the stage3)?
>
> > +struct case_range
> > +{
> > +  /* Default constructor.  */
> > +  case_range ():
> > +    m_min (NULL_TREE), m_max (NULL_TREE)
>
> I admit I'm never sure about coding conventions for C++,
> but shouldn't there be a space before :, or even better :
> be on the next line before m_min ?
>
>         Jakub
>

  reply	other threads:[~2019-11-05 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 [this message]
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
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='CAFiYyc0j3uYK9Z5LVtcoG0r9PhXB=Pj5kTy6vU0XzV7H=edO2A@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jakub@redhat.com \
    --cc=kazu@gcc.gnu.org \
    --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).