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] Improve DSE to handle redundant zero initializations.


Thanks for doing this.

Matthew Beliveau <mbelivea@redhat.com> writes:
> diff --git gcc/tree-ssa-dse.c gcc/tree-ssa-dse.c
> index 5b7c4fc6d1a..dcaeb8edbfe 100644
> --- gcc/tree-ssa-dse.c
> +++ gcc/tree-ssa-dse.c
> @@ -628,11 +628,8 @@ dse_optimize_redundant_stores (gimple *stmt)
>        tree fndecl;
>        if ((is_gimple_assign (use_stmt)
>  	   && gimple_vdef (use_stmt)
> -	   && ((gimple_assign_rhs_code (use_stmt) == CONSTRUCTOR
> -	        && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (use_stmt)) == 0
> -	        && !gimple_clobber_p (stmt))
> -	       || (gimple_assign_rhs_code (use_stmt) == INTEGER_CST
> -		   && integer_zerop (gimple_assign_rhs1 (use_stmt)))))
> +	   && initializer_zerop (gimple_op (use_stmt, 1), NULL)
> +	   && !gimple_clobber_p (stmt))
>  	  || (gimple_call_builtin_p (use_stmt, BUILT_IN_NORMAL)
>  	      && (fndecl = gimple_call_fndecl (use_stmt)) != NULL
>  	      && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMSET
> @@ -1027,15 +1024,13 @@ dse_dom_walker::dse_optimize_stmt (gimple_stmt_iterator *gsi)
>      {
>        bool by_clobber_p = false;
>  
> -      /* First see if this store is a CONSTRUCTOR and if there
> -	 are subsequent CONSTRUCTOR stores which are totally
> -	 subsumed by this statement.  If so remove the subsequent
> -	 CONSTRUCTOR store.
> +      /* Check if this store initalizes zero, or some aggregate of zeros,
> +	 and check if there are subsequent stores which are subsumed by this
> +	 statement.  If so, remove the subsequent store.
>  
>  	 This will tend to make fewer calls into memset with longer
>  	 arguments.  */
> -      if (gimple_assign_rhs_code (stmt) == CONSTRUCTOR
> -	  && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (stmt)) == 0
> +      if (initializer_zerop (gimple_op (stmt, 1), NULL)
>  	  && !gimple_clobber_p (stmt))
>  	dse_optimize_redundant_stores (stmt);
>  

In addition to Jeff's comment, the original choice of gimple_assign_rhs1
is the preferred way to write this (applies to both hunks).

Richard


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