This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Use bitwise AND/OR/XOR if possible to implement &&, ||, !
- From: Andi Kleen <andi at firstfloor dot org>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 26 Aug 2008 14:39:32 +0200
- Subject: Re: [PATCH] Use bitwise AND/OR/XOR if possible to implement &&, ||, !
- References: <g90mvi$i35$1@ger.gmane.org>
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