[patch] Perform anonymous constant propagation during inlining

Eric Botcazou ebotcazou@adacore.com
Mon May 11 14:07:00 GMT 2015


> >Would you be OK with a slight variation of your earlier idea, i.e.
> >calling fold_stmt with a specific valueizer from fold_marked_statements
> >instead of the implicit no_follow_ssa_edges in the inliner?  Something
> >like:
> >
> >tree
> >follow_anonymous_single_use_edges (tree val)
> >{
> >
> >  if (TREE_CODE (val) == SSA_NAME
> >  
> >      && (!SSA_NAME_VAR (val) || DECL_IGNORED_P (SSA_NAME_VAR
> >      (var)))
> >      && has_single_use (val))
> >    
> >    return val
> >  
> >  return NULL_TREE;
> >
> >}
> 
> Yes, that works for me as well.

But not for GCC. :-)  The propagation per se works but, since the statement is 
not folded in the end, no replacement is made at all...

So we're back to square one and anonymous constant propagation seems to be the 
only way out at -O0.  The attached patch implements it in a less hackish way 
(and enables it unconditionally when optimizing as suggested by Jan) by doing 
it just before invoking fold_stmt on the marked statements so this should make 
folding more effective in the process. 

Tested (compiler only) on x86_64-suse-linux, OK for the mainline?


2015-05-11  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-inline.c: Include tree-ssa-propagate.h.
	(replace_constant_uses_in): New function.
	(fold_marked_statements): Call it before folding the statement.

	* gimple-expr.h (is_gimple_constant): Reorder.
	* tree-ssa-propagate.c (before_dom_children): Use inline accessor.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 3854 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150511/d6aeac50/attachment.bin>


More information about the Gcc-patches mailing list