This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Replace calls to types_compatible_p langhook by calls to tree_ssa_useless_type_conversion_1
- From: Michael Matz <matz at suse dot de>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 20 Jun 2007 16:26:33 +0200 (CEST)
- Subject: Re: [PATCH] Replace calls to types_compatible_p langhook by calls to tree_ssa_useless_type_conversion_1
- References: <Pine.LNX.4.64.0706201412500.24708@zhemvz.fhfr.qr>
Hi,
On Wed, 20 Jun 2007, Richard Guenther wrote:
> Index: gcc/fold-const.c
> ===================================================================
> *** gcc.orig/fold-const.c 2007-06-19 18:00:51.000000000 +0200
> --- gcc/fold-const.c 2007-06-20 13:18:18.000000000 +0200
> *************** fold_convert (tree type, tree arg)
> *** 2228,2236 ****
> || TREE_CODE (orig) == ERROR_MARK)
> return error_mark_node;
>
> ! if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig)
> ! || lang_hooks.types_compatible_p (TYPE_MAIN_VARIANT (type),
> ! TYPE_MAIN_VARIANT (orig)))
> return fold_build1 (NOP_EXPR, type, arg);
>
> switch (TREE_CODE (type))
> --- 2228,2234 ----
> || TREE_CODE (orig) == ERROR_MARK)
> return error_mark_node;
>
> ! if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig))
> return fold_build1 (NOP_EXPR, type, arg);
Are you sure here? Why remove the special case when the main variants are
not the same but a conversion between them is not necessary?
> Index: gcc/tree-vn.c
> ===================================================================
> *** gcc.orig/tree-vn.c 2007-02-20 21:08:26.000000000 +0100
> --- gcc/tree-vn.c 2007-06-20 11:44:58.000000000 +0200
> *************** expressions_equal_p (tree e1, tree e2)
> *** 123,129 ****
>
> }
> else if (TREE_CODE (e1) == TREE_CODE (e2)
> ! && (te1 == te2 || lang_hooks.types_compatible_p (te1, te2))
> && operand_equal_p (e1, e2, OEP_PURE_SAME))
> return true;
>
> --- 123,131 ----
>
> }
> else if (TREE_CODE (e1) == TREE_CODE (e2)
> ! && (te1 == te2
> ! || (tree_ssa_useless_type_conversion_1 (te1, te2)
> ! && tree_ssa_useless_type_conversion_1 (te2, te1)))
You sometimes used this pattern (uselessness forward and backward), which
captures an IMHO important property of types (namely some sort of type
equivalence), perhaps introduce an own predicate for this instead of
spelling it out each time? equivalent_types_p()?
Ciao,
Michael.