From: Jim Thompson <jim@netgate.com>
To: "Wiles, Keith" <keith.wiles@intel.com>
Cc: Aleksey Baulin <aleksey.baulin@gmail.com>,
Thomas Monjalon <thomas@monjalon.net>,
"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()
Date: Mon, 20 Nov 2017 11:21:47 -0600 [thread overview]
Message-ID: <E303DF32-0977-4341-A632-B39D7A02C252@netgate.com> (raw)
In-Reply-To: <D3302FD6-A529-497E-A470-5EBC1729EDF5@intel.com>
> On Nov 20, 2017, at 7:36 AM, Wiles, Keith <keith.wiles@intel.com> wrote:
>
>> On Nov 19, 2017, at 4:16 PM, Aleksey Baulin <aleksey.baulin@gmail.com> wrote:
>>
>> #ifndef unlikely
>> -#define unlikely(x) __builtin_expect((x),0)
>> +#define unlikely(x) __builtin_expect(!!(x), 0)
>
> I have not looked at the generated code, but does this add some extra instruction now to do the !!(x) ?
>
>> #endif /* unlikely */
>>
>> #endif /* _RTE_BRANCH_PREDICTION_H_ */
>> --
>> 2.7.4
>>
>
> Regards,
> Keith
>
With no ‘-O’, you get an extra cmpl instruction with the double negated unlikely() .vs the one without the ‘!!’.
The same assembly is generated with ‘-O’ as a compiler switch.
Tested on:
[jim@blackbox-1 ~]$ uname -a
Linux blackbox-1.netgate.com 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[jim@blackbox-1 ~]$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Jim
next prev parent reply other threads:[~2017-11-20 17:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-19 22:16 Aleksey Baulin
2017-11-20 13:36 ` Wiles, Keith
2017-11-20 17:21 ` Jim Thompson [this message]
2017-11-21 7:05 ` Aleksey Baulin
2018-01-12 15:35 ` Thomas Monjalon
2018-01-13 22:05 ` Aleksey Baulin
2018-01-13 22:24 ` Thomas Monjalon
2018-01-13 22:45 ` Aleksey Baulin
2018-01-14 17:17 ` Stephen Hemminger
2018-01-20 16:28 ` Thomas Monjalon
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=E303DF32-0977-4341-A632-B39D7A02C252@netgate.com \
--to=jim@netgate.com \
--cc=aleksey.baulin@gmail.com \
--cc=dev@dpdk.org \
--cc=keith.wiles@intel.com \
--cc=thomas@monjalon.net \
/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;
as well as URLs for NNTP newsgroup(s).