This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Why are bools cast to int in conditionals?
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Dan Nicolaescu <dann at godzilla dot ics dot uci dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 22 Apr 2004 01:10:25 +0000 (UTC)
- Subject: Re: [tree-ssa] Why are bools cast to int in conditionals?
- References: <200404212300.i3LN00GK015176@scanner2.ics.uci.edu>
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