This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa]: Loop LICM, take 2
- From: law at redhat dot com
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: Daniel Berlin <dberlin at dberlin dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 27 Aug 2003 14:47:04 -0600
- Subject: Re: [tree-ssa]: Loop LICM, take 2
- Reply-to: law at redhat dot com
In message <1061991008.3255.38.camel@frodo.toronto.redhat.com>, Diego Novillo w
rites:
>> > Why do you care whether the LHS of the assignment is an SSA
>> > name?
>>
>> Because we can't lift stores.
>>
>Again. Why?
>
> for (i = 0; i < 10; i++)
> {
> A[3] = x + y;
> B[i] += A[3] + i;
> }
>
>A[3] can be lifted. It has no reaching defs within the loop.
>B[i] can't. It has one reaching def within the loop.
>
>I think I need to see a test case here as well. I may be missing
>something.
>From what I've heard the number of opportunities to hoist stores up
is relatively small. The general preference should be do sink stores
down. For this particular case we could do either.
Sinking would look like:
First hoist x + y into a temporary.
t = x + y;
for (i = 0; i < 10; i++)
{
A[3] = t;
B[i] += t + i;
}
Then sink the store
t = x + y;
for (i = 0; i < 10; i++)
{
B[i] += t + i;
}
A[3] = t;
Hoisting is slightly better in this case since it ever so slightly
reduces the lifetime of t (t is no longer live at loop exit).
t = x + y;
A[3] = t;
for (i = 0; i < 10; i++)
{
B[i] += t + i;
}
But again, from what I've heard/read, hoisting stores isn't generally that
interesting. Sink them instead.
Jeff