This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Why are bools cast to int in conditionals?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]