Search Linux Wireless

RE: [PATCH net-next] drivers/net: Remove boolean comparisons to true/false

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux