public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: David Laight <David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org>
Cc: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>,
	David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	jeffrey.t.kirsher-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-wireless
	<linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: RE: [PATCH net-next] drivers/net: Remove boolean comparisons to true/false
Date: Fri, 10 Feb 2012 14:04:22 +0100	[thread overview]
Message-ID: <1328879062.2443.16.camel@edumazet-laptop> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B6E65-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>

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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-02-10 13:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09 10:27 [net-next 0/7][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2012-02-09 10:27 ` [net-next 1/7] e1000e: remove test that is always false Jeff Kirsher
2012-02-09 10:27 ` [net-next 2/7] e1000e: remove unnecessary returns from void functions Jeff Kirsher
2012-02-09 10:27 ` [net-next 3/7] e1000e: remove unnecessary parentheses Jeff Kirsher
2012-02-09 10:27 ` [net-next 4/7] e1000e: use true/false for bool autoneg_false Jeff Kirsher
2012-02-09 13:15   ` David Laight
2012-02-09 18:34     ` David Miller
     [not found]       ` <20120209.133413.349832435589531136.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-09 21:17         ` [PATCH net-next] drivers/net: Remove boolean comparisons to true/false Joe Perches
2012-02-09 21:28           ` Jeff Kirsher
2012-02-09 22:36             ` Allan, Bruce W
2012-02-09 23:08               ` Joe Perches
2012-02-10  6:46                 ` Julia Lawall
2012-02-10  9:32           ` David Laight
2012-02-10  9:50             ` Arend van Spriel
     [not found]             ` <AE90C24D6B3A694183C094C60CF0A2F6026B6E65-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2012-02-10 13:04               ` Eric Dumazet [this message]
2012-02-13  5:50           ` David Miller
2012-02-09 10:28 ` [net-next 6/7] e1000e: replace '1' with 'true' for boolean get_link_status Jeff Kirsher
2012-02-09 10:28 ` [net-next 7/7] igb: fix warning about unused function Jeff Kirsher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328879062.2443.16.camel@edumazet-laptop \
    --to=eric.dumazet-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=jeffrey.t.kirsher-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox