[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160113225446.GU17997@ZenIV.linux.org.uk>
Date: Wed, 13 Jan 2016 22:54:46 +0000
From: Al Viro <viro@...IV.linux.org.uk>
To: Chen Gang <chengang@...ndsoft.com.cn>
Cc: dhowells@...hat.com, akpm@...ux-foundation.org,
nicolas.iooss_linux@....org, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] fs: dcache: Use bool return value instead of int
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.
Powered by blists - more mailing lists