From: Al Viro <viro@ZenIV.linux.org.uk>
To: Chen Gang <chengang@emindsoft.com.cn>
Cc: dhowells@redhat.com, akpm@linux-foundation.org,
nicolas.iooss_linux@m4x.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: dcache: Use bool return value instead of int
Date: Wed, 13 Jan 2016 22:54:46 +0000 [thread overview]
Message-ID: <20160113225446.GU17997@ZenIV.linux.org.uk> (raw)
In-Reply-To: <5696D239.2000605@emindsoft.com.cn>
On Thu, Jan 14, 2016 at 06:39:53AM +0800, Chen Gang wrote:
> > As for the inlines... frankly, if gcc generates a different code from having
> > replaced int with bool in those, it's time to do something very nasty to
> > gcc developers.
> >
>
> Could you provide the related proof?
static inline _Bool f(.....)
{
return <int expression>;
}
...
if (f(.....))
should generate the code identical to
if ((_Bool)<int expression>)
which, in turn, should generate the code identical to
if (<int expression> != 0)
and
if (<int expression>)
Neither explicit nor implicit conversion to _Bool (the former by the explicit
cast, the latter - by declaring f() to return _Bool) matters at all when the
damn thing is inlined in a condition context. Conversion to _Bool is
equivalent to comparison with 0, and so is the use in condition of if() and
friends.
For something not inlined you might get different code generated due to a
difference in calling sequences of _Bool(...) and int(...); for inlined
case having one of those variants produce a better code means that compiler
has managed to miss some trivial optimization in all other variants.
And I'm yet to see any proof that gcc *does* fuck up in that fashion. It
might - dumb bugs happen to everyone, but I would not assume that they'd
managed to do something that bogys without experimental evidence.
next prev parent reply other threads:[~2016-01-13 22:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 21:30 chengang
2016-01-11 22:51 ` Al Viro
2016-01-12 21:42 ` Chen Gang
2016-01-12 22:21 ` Al Viro
2016-01-13 22:39 ` Chen Gang
2016-01-13 22:54 ` Al Viro [this message]
2016-01-14 15:39 ` Chen Gang
2016-01-24 21:19 ` Chen Gang
2016-01-24 21:27 ` Al Viro
2016-01-25 21:24 ` Chen Gang
2016-01-12 0:33 ` David Howells
2016-01-12 1:02 ` Al Viro
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=20160113225446.GU17997@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=chengang@emindsoft.com.cn \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.iooss_linux@m4x.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
Powered by JetHome