public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Dead Store Elimination
@ 2009-10-22  6:57 Pranav Bhandarkar
  2009-10-22 17:13 ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Pranav Bhandarkar @ 2009-10-22  6:57 UTC (permalink / raw)
  To: gcc

Hi,

A possible silly question about the dead store elimination pass. From
the documentation it is clear that the store S1 below is removed by
this pass (in dse.c)

*(addr) = value1;          // S1
.....
.....
*(addr) = value2          // S2 .. No read of "addr" between S1 and S2.
......
             = *(addr)       // Load
.......
end_of_the_function

However, consider a different example.

*(addr) = value1;      // S1
......
.....
end_of_the_function.

i.e. there is no store Sn that follows S1 along any path from S1 to
the end of the function and there is no read of addr following S1
either. Is the dse pass expected to remove such stores ? (I am
inclined to think that it should, but I am seeing a case where dse
doesnt remove such stores) . Further is the behaviour expected to be
different if the "addr" is based on  "fp" ?

TIA,
Pranav

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dead Store Elimination
  2009-10-22  6:57 Dead Store Elimination Pranav Bhandarkar
@ 2009-10-22 17:13 ` Richard Guenther
  2009-10-22 18:03   ` Pranav Bhandarkar
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Guenther @ 2009-10-22 17:13 UTC (permalink / raw)
  To: Pranav Bhandarkar; +Cc: gcc

On Thu, Oct 22, 2009 at 8:31 AM, Pranav Bhandarkar
<pranav.bhandarkar@gmail.com> wrote:
> Hi,
>
> A possible silly question about the dead store elimination pass. From
> the documentation it is clear that the store S1 below is removed by
> this pass (in dse.c)
>
> *(addr) = value1;          // S1
> .....
> .....
> *(addr) = value2          // S2 .. No read of "addr" between S1 and S2.
> ......
>             = *(addr)       // Load
> .......
> end_of_the_function
>
> However, consider a different example.
>
> *(addr) = value1;      // S1
> ......
> .....
> end_of_the_function.
>
> i.e. there is no store Sn that follows S1 along any path from S1 to
> the end of the function and there is no read of addr following S1
> either. Is the dse pass expected to remove such stores ? (I am
> inclined to think that it should, but I am seeing a case where dse
> doesnt remove such stores) . Further is the behaviour expected to be
> different if the "addr" is based on  "fp" ?

Are you talking about the tree dead-store elimination pass or
the RTL one?  Basically *addr = value1; cannot be removed
if addr does not point to local memory or if the pointed-to
memory escapes through a call-site that is dominated by this store.

Richard.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dead Store Elimination
  2009-10-22 17:13 ` Richard Guenther
@ 2009-10-22 18:03   ` Pranav Bhandarkar
  2009-10-22 18:26     ` Jeff Law
  2009-10-28  3:33     ` Jakub Jelinek
  0 siblings, 2 replies; 5+ messages in thread
From: Pranav Bhandarkar @ 2009-10-22 18:03 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc

> Are you talking about the tree dead-store elimination pass or
> the RTL one?  Basically *addr = value1; cannot be removed
> if addr does not point to local memory or if the pointed-to
> memory escapes through a call-site that is dominated by this store.

I am talking about the RTL dead-store elimination. In my case addr is
based on the stack pointer and the store is to a local variable on the
stack.

Thanks,
Pranav

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dead Store Elimination
  2009-10-22 18:03   ` Pranav Bhandarkar
@ 2009-10-22 18:26     ` Jeff Law
  2009-10-28  3:33     ` Jakub Jelinek
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Law @ 2009-10-22 18:26 UTC (permalink / raw)
  To: Pranav Bhandarkar; +Cc: Richard Guenther, gcc

On 10/22/09 11:14, Pranav Bhandarkar wrote:
>> Are you talking about the tree dead-store elimination pass or
>> the RTL one?  Basically *addr = value1; cannot be removed
>> if addr does not point to local memory or if the pointed-to
>> memory escapes through a call-site that is dominated by this store.
>>      
> I am talking about the RTL dead-store elimination. In my case addr is
> based on the stack pointer and the store is to a local variable on the
> stack.
>    
File a bug with a complete testcase.

I believe we're supposed to handle this, but I'm not absolutely certain 
we do (traditionally the way to handle this is to treat the return insn 
as storing into each stack slot for the purposes of dse analysis).

jeff


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dead Store Elimination
  2009-10-22 18:03   ` Pranav Bhandarkar
  2009-10-22 18:26     ` Jeff Law
@ 2009-10-28  3:33     ` Jakub Jelinek
  1 sibling, 0 replies; 5+ messages in thread
From: Jakub Jelinek @ 2009-10-28  3:33 UTC (permalink / raw)
  To: Pranav Bhandarkar; +Cc: Richard Guenther, gcc

On Thu, Oct 22, 2009 at 12:14:31PM -0500, Pranav Bhandarkar wrote:
> > Are you talking about the tree dead-store elimination pass or
> > the RTL one?  Basically *addr = value1; cannot be removed
> > if addr does not point to local memory or if the pointed-to
> > memory escapes through a call-site that is dominated by this store.
> 
> I am talking about the RTL dead-store elimination. In my case addr is
> based on the stack pointer and the store is to a local variable on the
> stack.

Just read the comments at the top of gcc/dse.c, it explains nicely what the
pass performs.  fp based stores are removed even when they are dead when
reaching end of function, sp based stores are not, because it would break
too much architectures.

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-10-27 20:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-22  6:57 Dead Store Elimination Pranav Bhandarkar
2009-10-22 17:13 ` Richard Guenther
2009-10-22 18:03   ` Pranav Bhandarkar
2009-10-22 18:26     ` Jeff Law
2009-10-28  3:33     ` Jakub Jelinek

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).