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: [patch] Store motion rewrite


Hello,

> There seems to be a problem with the code somewhere.
> Consider the trivial test case 
> 
> 	static int x;
> 	void foo(int p, int q, int r)
> 	{
> 	  x = q;
> 	  if (p)
> 	    x = r;
> 	}
> 
> I would expect store motion to notice the two stores,
> that the one dominates the other (so there are no path
> issues), and sink the store below the if.  I.e.
> 
> 	  tmp = q;
> 	  if (p)
> 	    tmp = r;
> 	  x = tmp;
> 
> The code does in fact notice the two stores:
> 
> ST_avail and ST_antic (shown under loads..)
> LDST list: 
>   Pattern (  0): (mem/f:SI (symbol_ref:SI ("x")) [2 x+0 S4 A32])
>          Loads : (insn_list 16 (insn_list 11 (nil)))
>         Stores : (insn_list 16 (insn_list 11 (nil)))
> 
> But we only delete insn 11, and decide to insert its replacement
> on the 0->2 edge.  We wind up with a trivial transformation of
> the code that doesn't help in the least.  Indeed, the resulting
> code is arguably worse.

but as far as I understand the code it does exactly what it is supposed
to -- it moves the computations so that there is no partially redundant
store and simultaneously minimizes the lifespan of the temporary
variables created :-(

Zdenek


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