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]

[PATCH] Really make copyprop propagate constants


Back last year I made copyprop also propagate constants (if a copy
chain ultimatively ends in a constant).  At least I thought so, but
it turns out I missed a piece.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-03-25  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-copy.c (stmt_may_generate_copy): Copies from constants
	also generate copies.
	(fini_copy_prop): Handle constant values properly.

Index: gcc/tree-ssa-copy.c
===================================================================
*** gcc/tree-ssa-copy.c	(revision 171450)
--- gcc/tree-ssa-copy.c	(working copy)
*************** stmt_may_generate_copy (gimple stmt)
*** 315,322 ****
    /* Otherwise, the only statements that generate useful copies are
       assignments whose RHS is just an SSA name that doesn't flow
       through abnormal edges.  */
!   return (gimple_assign_rhs_code (stmt) == SSA_NAME
! 	  && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_assign_rhs1 (stmt)));
  }
  
  
--- 315,323 ----
    /* Otherwise, the only statements that generate useful copies are
       assignments whose RHS is just an SSA name that doesn't flow
       through abnormal edges.  */
!   return ((gimple_assign_rhs_code (stmt) == SSA_NAME
! 	   && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_assign_rhs1 (stmt)))
! 	  || is_gimple_min_invariant (gimple_assign_rhs1 (stmt)));
  }
  
  
*************** fini_copy_prop (void)
*** 771,776 ****
--- 772,778 ----
  	 of the representative to the first solution we find if
  	 it doesn't have one already.  */
        if (copy_of[i].value != var
+ 	  && TREE_CODE (copy_of[i].value) == SSA_NAME
  	  && POINTER_TYPE_P (TREE_TYPE (var))
  	  && SSA_NAME_PTR_INFO (var)
  	  && !SSA_NAME_PTR_INFO (copy_of[i].value))


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