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 ability of PRE to detect redundancies


On Thu, 25 Nov 2004, Daniel Berlin wrote:
> +/* Return the folded version of T if T, when folded, is a gimple
> +   min_invariant.  Otherwise, return T. */
> +
> +static tree
> +fully_constant_expression (tree t)
> +{
> +  tree folded;
> +  switch (TREE_CODE_CLASS (TREE_CODE (t)))
> +    {
> +    case tcc_comparison:
> +    case tcc_binary:
> +      folded = fold_binary_to_constant (TREE_CODE (t), TREE_TYPE (t),
> +					TREE_OPERAND (t, 0),
> +					TREE_OPERAND (t, 1));
> +      break;
> +    case tcc_unary:
> +      folded = fold_unary_to_constant (TREE_CODE (t), TREE_TYPE (t),
> +				       TREE_OPERAND (t, 0));
> +      break;
> +    default:
> +      folded = t;
> +    }
> +  if (folded && is_gimple_min_invariant (folded))
> +    return folded;
> +
> +  return t;
> +}

Why not just

static tree
fully_constant_expression (tree t)
{
  tree folded = fold (t);
  if (folded != t && is_gimple_min_invariant (folded))
    return folded;
  return t;
}

which may also simplify the task of teaching GNV-PRE that "x + 1"
is equivalent to "1 + x", or that "x + x" is equivalent to "x * 2",
etc..

As to suitability for gcc 4.0 vs gcc 4.1, I'll leave that to others
more qualified than myself.  But no change on SPEC is a bit of a
disappointment.

Roger
--


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