Re: Optimize n?rotate(x,n):x

2014-05-14 Thread Jeff Law
On 05/01/14 15:52, Marc Glisse wrote: Hello, here is the latest version. Reviewers seemed happy with different versions, so I went for the simplest one. We only give up on the transformation if we are optimizing for speed, the short-cut has probability 50% and the operation the branch is

Re: Optimize n?rotate(x,n):x

2014-05-01 Thread Marc Glisse
Hello, here is the latest version. Reviewers seemed happy with different versions, so I went for the simplest one. We only give up on the transformation if we are optimizing for speed, the short-cut has probability 50% and the operation the branch is avoiding is expensive (i.e. only

Re: Optimize n?rotate(x,n):x

2014-04-23 Thread Marc Glisse
Honza, any comment on Richard's question? On Tue, 15 Apr 2014, Richard Biener wrote: On Mon, Apr 14, 2014 at 6:40 PM, Marc Glisse marc.gli...@inria.fr wrote: On Mon, 14 Apr 2014, Richard Biener wrote: + /* If the special case has a high probability, keep it. */ + if (EDGE_PRED

Re: Optimize n?rotate(x,n):x

2014-04-23 Thread Jan Hubicka
Honza, any comment on Richard's question? On Tue, 15 Apr 2014, Richard Biener wrote: On Mon, Apr 14, 2014 at 6:40 PM, Marc Glisse marc.gli...@inria.fr wrote: On Mon, 14 Apr 2014, Richard Biener wrote: + /* If the special case has a high probability, keep it. */ + if (EDGE_PRED

Re: Optimize n?rotate(x,n):x

2014-04-23 Thread Marc Glisse
On Wed, 23 Apr 2014, Jan Hubicka wrote: + /* Now optimize (x != 0) ? x + y : y to just y. + The following condition is too restrictive, there can easily be another + stmt in middle_bb, for instance a CONVERT_EXPR for the second argument. */ + gimple assign = last_and_only_stmt

Re: Optimize n?rotate(x,n):x

2014-04-23 Thread Jan Hubicka
Thank you for the comments. If I understand correctly: - it is always ok to look at edge-probability (no need to check that the probabilities are available as Richard feared) Actually with -fno-guess-branch-probabilities (default only at -O0) the probability is not computed. You can

Re: Optimize n?rotate(x,n):x

2014-04-15 Thread Richard Biener
On Mon, Apr 14, 2014 at 6:40 PM, Marc Glisse marc.gli...@inria.fr wrote: On Mon, 14 Apr 2014, Richard Biener wrote: + /* If the special case has a high probability, keep it. */ + if (EDGE_PRED (middle_bb, 0)-probability PROB_EVEN) I suppose Honza has a comment on how to test this

Re: Optimize n?rotate(x,n):x

2014-04-14 Thread Richard Biener
On Sun, Apr 13, 2014 at 10:58 PM, Marc Glisse marc.gli...@inria.fr wrote: On Mon, 3 Mar 2014, Richard Biener wrote: On Sat, Mar 1, 2014 at 3:33 PM, Marc Glisse marc.gli...@inria.fr wrote: Hello, again, a stage 1 patch that I will ping then, but early comments are welcome. PR 59100 was

Re: Optimize n?rotate(x,n):x

2014-04-14 Thread Marc Glisse
On Mon, 14 Apr 2014, Richard Biener wrote: + /* If the special case has a high probability, keep it. */ + if (EDGE_PRED (middle_bb, 0)-probability PROB_EVEN) I suppose Honza has a comment on how to test this properly (not sure if -probability or -frequency is always initialized properly).

Re: Optimize n?rotate(x,n):x

2014-04-13 Thread Marc Glisse
On Mon, 3 Mar 2014, Richard Biener wrote: On Sat, Mar 1, 2014 at 3:33 PM, Marc Glisse marc.gli...@inria.fr wrote: Hello, again, a stage 1 patch that I will ping then, but early comments are welcome. PR 59100 was asking to transform n?rotate(x,n):x to rotate(x,n) (because it can be hard to

Re: Optimize n?rotate(x,n):x

2014-03-03 Thread Richard Biener
On Sat, Mar 1, 2014 at 3:33 PM, Marc Glisse marc.gli...@inria.fr wrote: Hello, again, a stage 1 patch that I will ping then, but early comments are welcome. PR 59100 was asking to transform n?rotate(x,n):x to rotate(x,n) (because it can be hard to write a strictly valid rotate in plain C).

Optimize n?rotate(x,n):x

2014-03-01 Thread Marc Glisse
Hello, again, a stage 1 patch that I will ping then, but early comments are welcome. PR 59100 was asking to transform n?rotate(x,n):x to rotate(x,n) (because it can be hard to write a strictly valid rotate in plain C). The operation is really: (x != neutral) ? x op y : y where neutral is