[tree-ssa] Why are bools cast to int in conditionals?
Joseph S. Myers
jsm@polyomino.org.uk
Thu Apr 22 15:42:00 GMT 2004
On Thu, 22 Apr 2004, Paul Koning wrote:
> I sure don't understand this. In most languages (Pascal, Algol, etc.)
> Boolean is a first-class type, and the notion of implicit conversion
> to int simply does not exist.
Whether the conversion is implicit or explicit is irrelevant to whether
fold can make these transformations. The question is, if fold is given a
comparison between CONVERT_EXPR / NOP_EXPR / NON_LVALUE_EXPR nodes which
have integer types and an argument of boolean type, it is legitimate for
fold to change it into a direct comparision between the booleans
(obviously preserving the type of the *result* of the comparison). If
this is a valid transformation on trees, then the C front end can generate
trees in the form corresponding to C semantics in the expectation that
fold will deal with optimizing them back to comparisons of booleans. If
different languages pass the same trees to fold with different semantics
for those trees, either a langhook is needed or the transformation can
only be done on GIMPLE when the trees have language-independent semantics.
Is there anything (apart from the odd handling of enums) that
shorten_compare does that depends on language-specific properties of trees
and that therefore is not appropriate to be part of fold()?
--
Joseph S. Myers
jsm@polyomino.org.uk
More information about the Gcc
mailing list