[PATCH, dataflow] PR47525 DCE fails to eliminate dead calls to pure functions

Kenneth Zadeck zadeck@naturalbridge.com
Sat Jan 29 00:53:00 GMT 2011


the patch is ok for inclusion in some version.

a release manager must approve it for 4.6.

Kenny

On 01/28/2011 06:06 PM, Peter Bergner wrote:
> Tracking down some test suite failures while doing a --with-cpu=power7 build,
> I noticed that DCE is no longer eliminating dead calls to const or pure
> function calls.  This is due to all global registers being added to every
> call's use and def chains, even though const functions won't reference them
> at all and pure functions won't set them.
>
> The following patch fixes that and has bootstrapped and regtested with
> no regressions.  This is a regression since it works in gcc 4.3, but
> fails in gcc 4.4, 4.5 and trunk, but I understand it only a performance
> issue and not a correctness issue.
>
> Is that patch OK?  If so, do we want this in mainline now or after 4.6
> has branched?
>
> Peter
>
>
> 	PR rtl-optimization/47525
> 	* df-scan.c: Update copyright years.
> 	(df_get_call_refs): Do not mark global registers as DF_REF_REG_USE
> 	and non-clobber DF_REF_REG_DEF for calls to const and pure functions.
>
> Index: df-scan.c
> ===================================================================
> --- df-scan.c	(revision 169365)
> +++ df-scan.c	(working copy)
> @@ -1,6 +1,6 @@
>   /* Scanning of rtl for dataflow analysis.
>      Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
> -   2008, 2009, 2010 Free Software Foundation, Inc.
> +   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
>      Originally contributed by Michael P. Hayes
>                (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
>      Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
> @@ -3360,16 +3360,19 @@ df_get_call_refs (struct df_collection_r
>   		 NULL, bb, insn_info, DF_REF_REG_USE,
>   		 DF_REF_CALL_STACK_USAGE | flags);
>
> -  /* Calls may also reference any of the global registers,
> -     so they are recorded as used.  */
> -  for (i = 0; i<  FIRST_PSEUDO_REGISTER; i++)
> -    if (global_regs[i])
> -      {
> -	df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
> -		       NULL, bb, insn_info, DF_REF_REG_USE, flags);
> -	df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
> -		       NULL, bb, insn_info, DF_REF_REG_DEF, flags);
> -      }
> +  /* Calls to const functions cannot access any global registers and calls to
> +     pure functions cannot set them.  All other calls may reference any of the
> +     global registers, so they are recorded as used.  */
> +  if (!RTL_CONST_CALL_P (insn_info->insn))
> +    for (i = 0; i<  FIRST_PSEUDO_REGISTER; i++)
> +      if (global_regs[i])
> +	{
> +	  df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
> +			 NULL, bb, insn_info, DF_REF_REG_USE, flags);
> +	  if (!RTL_PURE_CALL_P (insn_info->insn))
> +	    df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
> +			   NULL, bb, insn_info, DF_REF_REG_DEF, flags);
> +	}
>
>     is_sibling_call = SIBLING_CALL_P (insn_info->insn);
>     EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, ui, bi)
>
>



More information about the Gcc-patches mailing list