Michael, Thanks for your help. I struggled to understand tree-ssa-ter.c. Please see questions below.
I also tried the tree-ssa-ter.c from the trunk. Same results. Bingfeng > -----Original Message----- > From: Michael Matz [mailto:m...@suse.de] > Sent: 08 December 2011 13:50 > To: Richard Guenther > Cc: Bingfeng Mei; gcc@gcc.gnu.org > Subject: Re: Bug in Tree to RTL expansion? > > Hi, > > On Thu, 8 Dec 2011, Richard Guenther wrote: > > > > What I am not sure is whether the coalescing algorithm or the > > > expanding procedure is wrong here. > > The forwarding of _218 is wrong. TER shouldn't have marked it as being > able to forward (check the expand-detailed dump for the "Replacing > Expressions" section). Obviously it does think it can forward it, so > something is wrong in tree-ssa-ter.c. > > If you can't come up with a testcase that fails with some available > cross > compiler (though I wonder why, the tree-ssa parts of the compiler are > not > that target dependend, so maybe you can show similar forwarding with an > adjusted testcase for something publically available) you have to debug > it > yourself (I'm right now not aware of any known bug in 4.5 regarding > this > particular situation). > > There should be a call to kill_expr on the statement > ptr_h2_310 = ptr_h2_493 + 16; I tracked into how TER is executed. kill_expr is called but the kill_list are already all empty because mark_replaceable -> finished_with_expr clear all the kill_list. In addition, once replaceable_expressions is set by mark_replaceable. It doesn't seem it is ever cleared due to kill_expr or any other function. replaceable_expression is the only data structure passed to expand pass. > which should have killed the expression MEM[ptr_h2_493] (and hence _218) > from the available expressions. > > > Ciao, > Michael.