[tree-ssa] Why are bools cast to int in conditionals?
Joseph S. Myers
jsm@polyomino.org.uk
Thu Apr 22 02:02:00 GMT 2004
On Wed, 21 Apr 2004, Dan Nicolaescu wrote:
> In more "complex" cases the casts are not be eliminated by the tree
> optimizers:
>
> _Bool foo (_Bool a, _Bool b)
> {
> if (a != b)
Here, the usual arithmetic conversions are applied to the operands of !=,
which includes the integer promotions, which promote _Bool to int.
I think the front end should generate trees corresponding as closely as
possible to what the standard specifies (including these conversions),
leaving it to language-independent code (such as fold) to do
language-independent optimizations on them, rather than including in the
front ends optimizations that aren't language-dependent which would then
need duplicating in other front ends. It should be possible for fold to
remove the implicit conversions in such cases.
--
Joseph S. Myers
jsm@polyomino.org.uk
More information about the Gcc
mailing list