fold_convert question

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Sat Oct 16 03:16:00 GMT 2004


    No, fold_convert is required to be strongly type safe by the GCC
    middle-end.

I'm confused.  I thought the rules are that GIMPLE is *not* strongly
type safe.  We remove all conversions between compatible types.
So the definition for GIMPLE is compatible types, not identical types.

Subsequent to sending my last email I discovered that this relevant to
the ACATS failure in c61008a, though fixing this isn't enough, since
something else is broken (I don't know what yet, but I suspect its the
type replacement for inlining).

The issue is the call from setup_one_parameter.  It wants to make sure
that the argument is converted to the type of the parameter.  In the
original GENERIC tree of the CALL_EXPR in this case, it was converted to
that type with a VIEW_CONVERT_EXPR.  But that was stripped off because
the types were compatible.  Then when the call was inlined, we tried to
convert it back, but couldn't at middle-end level because it was an
ARRAY_TYPE.

      If a function calls fold_convert (T, X), then the tree
        type of the returned expression will/must always be T.

    i.e.  TREE_TYPE (fold_convert (T, X)) == T

I don't see why.  Isn't it enough that they be compatible (in the
meaning of the lang hook)?

    [Likewise calling fold on a tree of type T, must always return
    a tree of type T]

Right, because "fold" is called on GENERIC, but fold_convert only on
GIMPLE and the typing rules are different.

    Besides, the phrase "types are compatible" is purely a front-end
    concept, that doesn't exist in the middle-end.  

Sure it does!  See STRIP_USELESS_TYPE_CONVERSION.

    As an Ada person, I'm sure you appreciate not having fold_convert
    impose any notion of "type compatability" on gigi's trees, other
    than the semantics implied by the original trees themselves.

Exactly the other way around: I expect the middle-end to consistently
use the language hook that says what's compatible and what isn't.  If it's
not going to do that, then it shouldn't trip "useless" type conversions!



More information about the Gcc mailing list