[PATCH] Fix PR50204

Michael Matz matz@suse.de
Wed Oct 12 16:10:00 GMT 2011


Hi,


no need to test a phi argument with itself (testing arg0 != arg1 is not 
the right test, though, so remembering the candidate index):

> @@ -1948,18 +1958,35 @@ get_continuation_for_phi (gimple phi, ao
>       until we hit the phi argument definition that dominates the other one.  */
>    else if (nargs >= 2)
>      {
> -      tree arg0 = PHI_ARG_DEF (phi, 0);
> -      tree arg1;
> -      unsigned i = 1;
> -      do
> +      tree arg0, arg1;
> +      unsigned i;

unsigned j;

> +      /* Find a candidate for the virtual operand which definition
> +	 dominates those of all others.  */
> +      arg0 = PHI_ARG_DEF (phi, 0);

j = 0;

> +      if (!SSA_NAME_IS_DEFAULT_DEF (arg0))
> +	for (i = 1; i < nargs; ++i)
> +	  {
> +	    arg1 = PHI_ARG_DEF (phi, i);
> +	    if (SSA_NAME_IS_DEFAULT_DEF (arg1))
> +	      {
> +		arg0 = arg1;

j = i;

> +		break;
> +	      }
> +	    if (dominated_by_p (CDI_DOMINATORS,
> +				gimple_bb (SSA_NAME_DEF_STMT (arg0)),
> +				gimple_bb (SSA_NAME_DEF_STMT (arg1))))
> +	      arg0 = arg1;

, j = i;

> +	  }
> +
> +      /* Then pairwise reduce against the found candidate.  */
> +      for (i = 0; i < nargs; ++i)
>  	{
>  	  arg1 = PHI_ARG_DEF (phi, i);

if (i != j)

>  	  arg0 = get_continuation_for_phi_1 (phi, arg0, arg1, ref, visited);
>  	  if (!arg0)
>  	    return NULL_TREE;
> -
>  	}
> -      while (++i < nargs);


Ciao,
Michael.



More information about the Gcc-patches mailing list