This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to check that two ssa registers have the same symbolic value


On 5/30/07, Zdenek Dvorak <rakdver@kam.mff.cuni.cz> wrote:
Hello,

> "Daniel Berlin" <dberlin@dberlin.org> wrote on 29.05.2007 18:35:49:
>
> > On 5/29/07, Victor Kaplansky <VICTORK@il.ibm.com> wrote:
> > >
> > > Hello,
> > >
> > > I'm working on a pass performing store-sinking
> > > as in following example:
> > >
> > > if (c)
> > >   p[i] = x;
> > > else
> > >   p[i] = y;
> > >
> > > The idea is to perform store sinking:
> > >
> > > if (c)
> > >   tmp = x;
> > > else
> > >   tmp = y;
> > >
> > > a[i] = tmp;
> > >
> > > The objective is to help if-convert pass to get rid of conditional
> > > branches, which can be very expansive on some architectures.
> > >
> > You should extend tree-ssa-sink to do this, rather than write a
> > whole new pass.
> > It is one of the listed todos to use scalar promotion of stores like
> this.
>
> I looked into tree-ssa-sink pass. It seems like right now it doesn't sink
> statements without ssa register as LHS.

This isn't correct. It will happily sink things with ssa registers on the LHS. I'm not sure why you think otherwise.

The only thing it will not sink is loads ( !ZERO_SSA_OPERANDS (stmt,
SSA_OP_VUSE) will only catch actual VUSE's, not the vuse part of a
vdef)

Also, if you look at the todo, you will see

1. Sinking store only using scalar promotion (IE without moving the RHS):

This is exactly what you are trying to accomplish.

Note that the reason it often does not sink things with stores on the
LHS is because they may store to global variables and we don't want to
fuck this up.
You will run into the same problem, and will have to use the value
numbering to ensure we don't promote stores past the point of
something that could load from the same address.
When it comes to local pointers, this is easy.
For globals, not so much.


> Anyway even if it did, it woudn't > catch the case I'm trying to optimize.

You would have to add this transformation to tree-ssa-sink; still, a lot
of code would be shared.

Right.



> I think that transformation I'm > trying > is more similar to a store sinking which is done as part of lim pass. > Am I missing something?

That the code above does not necessarily have to be inside a loop.

Right.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]