This is the mail archive of the gcc-patches@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: [PATCH] Use bitwise AND/OR/XOR if possible to implement &&, ||, !


Paolo Bonzini <bonzini@gnu.org> writes:

> This patch allows GCC to compile boolean &&, ||, ! to simple bitwise
> AND, OR and XOR operations, when the operands are known to be truth
> values.

That is they come out of an earlier truth generating operator like
! || && > < etc., right? For bool variables read from memory 
or coming from function it would be unsafe because
the values are not necessarily 0 or 1 there. And then could give for 
example wrong (or at least non 0/1) results with xor. Or or could
generate a non 0/1 result (then it would be only safe when
the value is only tested, but not saved)

Also when it comes from an earlier truth generating operator
using jumps or set* I'm not sure it's really a win because
it could be short circuited in other ways too.

-Andi


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