[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1328879062.2443.16.camel@edumazet-laptop>
Date: Fri, 10 Feb 2012 14:04:22 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: David Laight <David.Laight@...LAB.COM>
Cc: Joe Perches <joe@...ches.com>, David Miller <davem@...emloft.net>,
jeffrey.t.kirsher@...el.com, netdev@...r.kernel.org,
linux-wireless <linux-wireless@...r.kernel.org>
Subject: RE: [PATCH net-next] drivers/net: Remove boolean comparisons to
true/false
Le vendredi 10 février 2012 à 09:32 +0000, David Laight a écrit :
> The generated code is particularly horrid for boolean arithmetic.
> IIRC:
> bool_var &= bool_var_1;
> typically requires a sequence of compare and branch instructions.
>
I suggest you try to upgrade your old compiler and/or always check your
assertions before posting on netdev such claims.
bool_var &= bool_var_1;
generates a single AND instruction, no compare, no branch.
It would be a failure from compiler optimizer if that was the case.
And (bool_var ? 1 : 0) or (!!bool_var) are NOP for a compiler as well.
(Only one movzbl instruction to convert a byte to a word if context
requires this)
Only difference for bool or unsigned int vars is type promotion, and
fact that compiler knows that 'bool' only can be 0 or 1, so allows more
optimisations than plain "unsigned int".
Really, bools are not evil if well used.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists