[PATCH]: Improve ability of PRE to detect redundancies
Roger Sayle
roger@eyesopen.com
Fri Nov 26 05:30:00 GMT 2004
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
--
More information about the Gcc-patches
mailing list