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]

[tree-ssa] Constant propagate into PHIs


This patch allows us to propagate constants into PHI nodes and utilize
equivalences from phi nodes which look like

<var> = PHI (constant)

	* tree-ssa-dom.c (optimize_block): If a PHI has a single argument
	that is a constant, then that creates a useful equivalence.
	Propagate constant values into PHI nodes.

	* tree-flow-inline.h (may_propagate_copy): Allow RHS to be a 
	constant.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.11
diff -c -3 -p -r1.1.2.11 tree-ssa-dom.c
*** tree-ssa-dom.c	25 Jul 2003 17:42:37 -0000	1.1.2.11
--- tree-ssa-dom.c	28 Jul 2003 17:42:07 -0000
*************** optimize_block (basic_block bb, tree par
*** 261,267 ****
       creates an equivalence we can record into the const_and_copies table.  
*/
    for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
      if (PHI_NUM_ARGS (phi) == 1
! 	&& TREE_CODE (PHI_ARG_DEF (phi, 0)) == SSA_NAME
  	&& may_propagate_copy (PHI_RESULT (phi), PHI_ARG_DEF (phi, 0)))
        set_value_for (PHI_RESULT (phi), PHI_ARG_DEF (phi, 0), 
const_and_copies);
  
--- 261,268 ----
       creates an equivalence we can record into the const_and_copies table.  
*/
    for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
      if (PHI_NUM_ARGS (phi) == 1
! 	&& (TREE_CODE (PHI_ARG_DEF (phi, 0)) == SSA_NAME
! 	    || TREE_CONSTANT (PHI_ARG_DEF (phi, 0)))
  	&& may_propagate_copy (PHI_RESULT (phi), PHI_ARG_DEF (phi, 0)))
        set_value_for (PHI_RESULT (phi), PHI_ARG_DEF (phi, 0), 
const_and_copies);
  
*************** optimize_block (basic_block bb, tree par
*** 286,297 ****
  		  if (! SSA_VAR_P (*orig_p))
  		    break;
  
- 		  /* FIXME.  We should be able to propagate constants into
- 		     PHI nodes in the not too distant future.  */
  		  new = get_value_for (*orig_p, const_and_copies);
  		  if (new
! 		      && TREE_CODE (new) == SSA_NAME
! 		      && may_propagate_copy (new, *orig_p))
  		    *orig_p = new;
  		  break;
  		}
--- 287,298 ----
  		  if (! SSA_VAR_P (*orig_p))
  		    break;
  
  		  new = get_value_for (*orig_p, const_and_copies);
+ 		  /* We want to allow copy propagation as well as constant
+ 		     propagation.  */
  		  if (new
! 		      && (TREE_CODE (new) == SSA_NAME || TREE_CONSTANT (new))
! 		      && may_propagate_copy (*orig_p, new))
  		    *orig_p = new;
  		  break;
  		}
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.45
diff -c -3 -p -r1.1.2.45 tree-flow-inline.h
*** tree-flow-inline.h	23 Jul 2003 23:48:15 -0000	1.1.2.45
--- tree-flow-inline.h	28 Jul 2003 17:42:07 -0000
*************** static inline bool
*** 540,546 ****
  may_propagate_copy (tree dest, tree orig)
  {
    return (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI (dest)
! 	  && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig)
  	  && !DECL_HARD_REGISTER (SSA_NAME_VAR (dest)));
  }
  
--- 540,547 ----
  may_propagate_copy (tree dest, tree orig)
  {
    return (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI (dest)
! 	  && (TREE_CONSTANT (orig)
! 	      || !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig))
  	  && !DECL_HARD_REGISTER (SSA_NAME_VAR (dest)));
  }
  





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