Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-15 Thread Richard Biener via Gcc-patches
On Mon, Oct 12, 2020 at 3:02 PM Martin Liška 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 >

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-14 Thread Andrew MacLeod via Gcc-patches
On 10/12/20 8:39 AM, Martin Liška wrote: On 10/6/20 4:12 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 03:48:38PM +0200, Martin Liška wrote: On 10/6/20 9:47 AM, Richard Biener wrote: But is it really extensible with the current implementation?  I doubt so. I must agree with the

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-12 Thread Martin Liška
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

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-12 Thread Jakub Jelinek via Gcc-patches
On Mon, Oct 12, 2020 at 02:39:24PM +0200, Martin Liška wrote: > All right, I started to use init_range_entry in combination with > linearize_expr_tree. > One thing I have problem with is that linearize_expr_tree doesn't properly > mark > all statements as visited for cases like: Not sure if

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-12 Thread Martin Liška
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

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-12 Thread Martin Liška
On 10/6/20 4:12 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 03:48:38PM +0200, Martin Liška wrote: On 10/6/20 9:47 AM, Richard Biener wrote: But is it really extensible with the current implementation? I doubt so. I must agree with the statement. So let's make the pass properly. I would

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-07 Thread Richard Biener via Gcc-patches
On Tue, Oct 6, 2020 at 4:03 PM Martin Liška wrote: > > On 10/6/20 9:47 AM, Richard Biener wrote: > > But is it really extensible with the current implementation? I doubt so. > > I must agree with the statement. So let's make the pass properly. > I would need a help with the algorithm where I'm

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 03:48:38PM +0200, Martin Liška wrote: > On 10/6/20 9:47 AM, Richard Biener wrote: > > But is it really extensible with the current implementation? I doubt so. > > I must agree with the statement. So let's make the pass properly. > I would need a help with the algorithm

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Martin Liška
On 10/6/20 9:47 AM, Richard Biener wrote: But is it really extensible with the current implementation? I doubt so. I must agree with the statement. So let's make the pass properly. I would need a help with the algorithm where I'm planning to do the following steps: 1) for each BB ending with

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Richard Biener via Gcc-patches
On Tue, Oct 6, 2020 at 3:09 PM Martin Liška wrote: > > On 10/6/20 2:56 PM, Andrew MacLeod wrote: > > Ah, by just using the outgoing_range class, all you are getting is static > > edges. so a TRUE edge is always a [1,1] and a false edge is [0,0] > > I provided that class so you could get the

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 9:09 AM, Martin Liška wrote: On 10/6/20 2:56 PM, Andrew MacLeod wrote: Ah, by just using the outgoing_range class, all you are getting is static edges.  so a TRUE edge is always a [1,1] and a false edge is [0,0] I provided that class so you could get the constant edges on switches.

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Martin Liška
On 10/6/20 2:56 PM, Andrew MacLeod wrote: Ah, by just using the outgoing_range class, all you are getting is static  edges.  so a TRUE edge is always a [1,1] and a false edge is [0,0] I provided that class so you could get the constant edges on switches. if you want to get actual ranges for

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 8:09 AM, Martin Liška wrote: On 10/2/20 4:19 PM, Andrew MacLeod wrote: On 10/2/20 9:26 AM, Martin Liška wrote: Yes, you simply get all sorts of conditions that hold when a condition is true, not just those based on the SSA name you put in.  But it occured to me that the use-case is

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Martin Liška
On 10/2/20 4:19 PM, Andrew MacLeod wrote: On 10/2/20 9:26 AM, Martin Liška wrote: Yes, you simply get all sorts of conditions that hold when a condition is true, not just those based on the SSA name you put in.  But it occured to me that the use-case is somewhat different - for

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Richard Biener via Gcc-patches
On Fri, Oct 2, 2020 at 3:23 PM Martin Liška wrote: > > On 9/24/20 2:41 PM, Richard Biener wrote: > > On Wed, Sep 2, 2020 at 1:53 PM Martin Liška wrote: > >> > >> On 9/1/20 4:50 PM, David Malcolm wrote: > >>> Hope this is constructive > >>> Dave > >> > >> Thank you David. All of them very very

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-02 Thread Andrew MacLeod via Gcc-patches
On 10/2/20 9:26 AM, Martin Liška wrote: Yes, you simply get all sorts of conditions that hold when a condition is true, not just those based on the SSA name you put in.  But it occured to me that the use-case is somewhat different - for switch-conversion you want to know whether the test

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-02 Thread Martin Liška
On 9/29/20 10:46 AM, Richard Biener wrote: On Fri, Sep 25, 2020 at 4:05 PM Martin Liška wrote: On 9/24/20 2:41 PM, Richard Biener wrote: On Wed, Sep 2, 2020 at 1:53 PM Martin Liška wrote: On 9/1/20 4:50 PM, David Malcolm wrote: Hope this is constructive Dave Thank you David. All of

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-02 Thread Martin Liška
On 9/24/20 2:41 PM, Richard Biener wrote: On Wed, Sep 2, 2020 at 1:53 PM Martin Liška wrote: On 9/1/20 4:50 PM, David Malcolm wrote: Hope this is constructive Dave Thank you David. All of them very very useful! There's updated version of the patch. I noticed several functions without a

Re: [PATCH] Add if-chain to switch conversion pass.

2020-09-29 Thread Richard Biener via Gcc-patches
On Fri, Sep 25, 2020 at 4:05 PM Martin Liška wrote: > > On 9/24/20 2:41 PM, Richard Biener wrote: > > On Wed, Sep 2, 2020 at 1:53 PM Martin Liška wrote: > >> > >> On 9/1/20 4:50 PM, David Malcolm wrote: > >>> Hope this is constructive > >>> Dave > >> > >> Thank you David. All of them very very

Re: [PATCH] Add if-chain to switch conversion pass.

2020-09-25 Thread Martin Liška
On 9/24/20 2:41 PM, Richard Biener wrote: On Wed, Sep 2, 2020 at 1:53 PM Martin Liška wrote: On 9/1/20 4:50 PM, David Malcolm wrote: Hope this is constructive Dave Thank you David. All of them very very useful! There's updated version of the patch. Hey. What a juicy patch review! I

Re: [PATCH] Add if-chain to switch conversion pass.

2020-09-24 Thread Richard Biener via Gcc-patches
On Wed, Sep 2, 2020 at 1:53 PM Martin Liška wrote: > > On 9/1/20 4:50 PM, David Malcolm wrote: > > Hope this is constructive > > Dave > > Thank you David. All of them very very useful! > > There's updated version of the patch. I noticed several functions without a function-level comment. -

Re: [PATCH] Add if-chain to switch conversion pass.

2020-09-21 Thread Martin Liška
PING^1 On 9/2/20 1:53 PM, Martin Liška wrote: On 9/1/20 4:50 PM, David Malcolm wrote: Hope this is constructive Dave Thank you David. All of them very very useful! There's updated version of the patch. Martin

Re: [PATCH] Add if-chain to switch conversion pass.

2020-09-02 Thread Martin Liška
200 Subject: [PATCH] Add if-chain to switch conversion pass. gcc/ChangeLog: PR tree-optimization/14799 PR ipa/88702 * Makefile.in: Add new gimple-if-to-switch.o. * common.opt: Add new option. * dbgcnt.def (DEBUG_COUNTER): Add new debug counter. * doc/invoke.texi: Document -fconvert-if-to-swi

Re: [PATCH] Add if-chain to switch conversion pass.

2020-09-01 Thread David Malcolm via Gcc-patches
On Tue, 2020-09-01 at 13:47 +0200, Martin Liška wrote: > Hello. > > There's a new version of the patch attempt. I mentioned couple of > issues with the v1 here: > https://gcc.gnu.org/pipermail/gcc-patches/2020-March/542821.html > > The patch addresses the biggest blocker which fact that the >

Re: [PATCH] Add if-chain to switch conversion pass.

2020-09-01 Thread Martin Liška
Hello. There's a new version of the patch attempt. I mentioned couple of issues with the v1 here: https://gcc.gnu.org/pipermail/gcc-patches/2020-March/542821.html The patch addresses the biggest blocker which fact that the optimization was done unconditionally. Now the transformation happens

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-14 Thread Bernhard Reutner-Fischer
On Thu, 14 Nov 2019 10:41:25 +0100 Martin Liška wrote: > On 11/6/19 10:02 PM, Bernhard Reutner-Fischer wrote: > > Also why do you punt on duplicate conditions like in > > > >> +++ b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-4.c > >> +int main(int argc, char **argv) > >> +{ > >> + if (argc

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-14 Thread Richard Biener
On Thu, Nov 14, 2019 at 10:39 AM Martin Liška wrote: > > On 11/5/19 1:38 PM, Richard Biener wrote: > > On Mon, Nov 4, 2019 at 3:49 PM Jakub Jelinek 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

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-14 Thread Martin Liška
On 11/13/19 4:43 PM, Michael Matz wrote: Hi, On Wed, 13 Nov 2019, Martin Liška wrote: Not a review, just a few questions: Hello. Thank you for it. 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,

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-14 Thread Martin Liška
On 11/6/19 10:02 PM, Bernhard Reutner-Fischer wrote: Also why do you punt on duplicate conditions like in +++ b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-4.c +int main(int argc, char **argv) +{ + if (argc == 1) + else if (argc == 2) + else if (argc == 3) + else if (argc == 4) + else if

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-14 Thread Martin Liška
On 11/5/19 1:38 PM, Richard Biener wrote: On Mon, Nov 4, 2019 at 3:49 PM Jakub Jelinek 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

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-13 Thread Michael Matz
Hi, On Wed, 13 Nov 2019, Martin Liška wrote: > > Not a review, just a few questions: > > Hello. > > Thank you for it. > > > > > 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 > >

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-13 Thread Martin Liška
On 11/4/19 3:48 PM, Jakub Jelinek 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

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-06 Thread Bernhard Reutner-Fischer
On Tue, 5 Nov 2019 13:38:27 +0100 Richard Biener wrote: > On Mon, Nov 4, 2019 at 3:49 PM Jakub Jelinek 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

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-05 Thread Richard Biener
On Mon, Nov 4, 2019 at 3:49 PM Jakub Jelinek 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

Re: [PATCH] Add if-chain to switch conversion pass.

2019-11-04 Thread Jakub Jelinek
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