This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] Re-structure tree_ssa_useless_type_conversion_1 to work towards a middle-end type system
- 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, gcc at gcc dot gnu dot org
- Date: Wed, 20 Jun 2007 16:17:06 +0200 (CEST)
- Subject: Re: [PATCH][RFC] Re-structure tree_ssa_useless_type_conversion_1 to work towards a middle-end type system
- References: <Pine.LNX.4.64.0706201354510.24708@zhemvz.fhfr.qr>
Hi,
On Wed, 20 Jun 2007, Richard Guenther wrote:
> /* If the outer type is (void *), then the conversion is not
> necessary.
> ??? This makes tree_ssa_useless_type_conversion_1 not
> transitive. */
Not this line itself makes it not transitive, but the fact that it still
relies on the frontends langhooks makes it so. Document that fact so it's
clear that when the final goal is implemented (langhook removed) this
doesn't violate transitivity.
> if (TREE_CODE (TREE_TYPE (outer_type)) == VOID_TYPE)
> return true;
>
> /* Return true if the conversion from INNER_TYPE to OUTER_TYPE is a
> ! useless type conversion, otherwise return false.
> ! This function implicitly defines the middle-end type system. The
> ! following invariants shall be fulfilled:
> !
> ! 1) tree_ssa_useless_type_conversion_1 is transitive. If
> ! a < b and b < c then a < c.
> !
> ! 2) tree_ssa_useless_type_conversion_1 is not communtative.
> ! From a < b does not follow a > b.
> !
> ! 3) Conversions are useless only if with the resulting type
Something is missing in this sentence. Perhaps "if _values_ with the
resulting type ..."? The whole sentence reads strange, though.
Operations are not applied to types but to values. Types actually _are_
exactly the set of operations applicable to values.
Perhaps reformulate the whole thing to something like:
3) Types define the available set of operations applicable to values. A
type conversion is useless if the operations for the target type is a
subset of the operations for the source type. For example casts to
void* are useless, casts from void* are not (void* can't be
dereferenced or offsetted, but copied, hence its set of operations is
a strict subset of that of all other data pointer types). Casts to
const T* are useless (can't be written to), casts from const T* to T*
are not.
Ciao,
Michael.