This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add VIEW_CONVERT_EXPR to operand_equal_p
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Eric Botcazou <ebotcazou at adacore dot com>, gcc-patches at gcc dot gnu dot org
- Date: Sun, 18 Oct 2015 19:14:48 +0200
- Subject: Re: Add VIEW_CONVERT_EXPR to operand_equal_p
- Authentication-results: sourceware.org; auth=none
- References: <20151014162944 dot GE16672 at kam dot mff dot cuni dot cz> <6561C1C3-366A-411C-BAEE-65E1C233BA16 at gmail dot com> <20151017165252 dot GJ5527 at kam dot mff dot cuni dot cz> <1833908 dot my5suBVC6X at polaris> <20151018160651 dot GA63497 at kam dot mff dot cuni dot cz> <9D70ECF7-CCB9-4D4E-955F-AD66BE7B22E3 at gmail dot com>
>
> Adding back the mode check is fine if all types with the same TYPE_CANONICAL have the same mode. Otherwise we'd regress here. I thought we do for
>
> Struct x { int i; };
> Typedef y x __attribute__((packed));
>
> And then doing
>
> X x;
> Y y;
> X = y;
Do you have any idea how to turn this into a testcase? I don't think we could
add packed attribute to typedef. Even in
gimple_canonical_types_compatible_p
/* Can't be the same type if they have different mode. */
if (TYPE_MODE (t1) != TYPE_MODE (t2))
return false;
(which IMO may be wrong WRT -mavx flags where modes of same types may be different
in different TUs)
Therefore I would say that TYPE_CANONICAL determine mode modulo the fact that
incoplete variant of a complete type will have VOIDmode instead of complete
type's mode (during non-LTO). That is why I allow mode changes for casts from
complete to incomplete.
In longer run I think that every query to useless_type_conversion_p that
contains incomplete types is a confused query. useless_type_conversion_p is
about operations on the value and there are no operations for incomplete type
(and function types). I know that ipa-icf-gimple and the following code in
gimplify-stmt checks this frequently:
/* The FEs may end up building ADDR_EXPRs early on a decl with
an incomplete type. Re-build ADDR_EXPRs in canonical form
here. */
if (!types_compatible_p (TREE_TYPE (op0), TREE_TYPE (TREE_TYPE (expr))))
*expr_p = build_fold_addr_expr (op0);
Taking address of incomplete type or functions, naturally, makes sense. We may
want to check something else here, like simply
TREE_TYPE (op0) != TREE_TYPE (TREE_TYPE (expr))
and once ipa-icf is cleanded up start sanity checking in usless_type_conversion
that we use it to force equality only on types that do have values.
We also can trip it when checking TYPE_METHOD_BASETYPE which may be incomplete.
This is in the code checking useless_type_conversion on functions that I think
are confused querries anyway - we need the ABI matcher, I am looking into that.
Honza
>
> Richard.
>
>
> >Honza
> >>
> >> --
> >> Eric Botcazou
>