Dead Store Elimination

Richard Guenther richard.guenther@gmail.com
Thu Oct 22 17:13:00 GMT 2009


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.



More information about the Gcc mailing list