Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Dec 2008 11:12:26 -0800 (PST)
From:      Nate Eldredge <neldredge@math.ucsd.edu>
To:        Stephen Montgomery-Smith <stephen@math.missouri.edu>
Cc:        Nate Eldredge <neldredge@math.ucsd.edu>, Garrett Cooper <yanefbsd@gmail.com>, Christoph Mallon <christoph.mallon@gmx.de>, FreeBSD Hackers <freebsd-hackers@freebsd.org>, Maksim Yevmenkin <maksim.yevmenkin@gmail.com>
Subject:   Re: RFC: small syscons and kbd patch
Message-ID:  <Pine.GSO.4.64.0812051105250.22402@zeno.ucsd.edu>
In-Reply-To: <493974DE.1050802@math.missouri.edu>
References:  <bb4a86c70812021701i621fdcfjb6a58a7f5cf781d5@mail.gmail.com> <7d6fde3d0812040324y3bf0901cy1f4a6d961362c314@mail.gmail.com> <bb4a86c70812040724w43ddec15yab72920d80d879d3@mail.gmail.com> <20081205072229.GE18652@hoeg.nl> <7d6fde3d0812050034y43a70ce8i49fbba92f9c8943b@mail.gmail.com> <7d6fde3d0812050035u6e3ea930o9e093830a8608444@mail.gmail.com> <20081205084441.GA29312@owl.midgard.homeip.net> <7d6fde3d0812050050l57684eebkf14f252d78b68ec0@mail.gmail.com> <4938F036.4010600@gmx.de> <7d6fde3d0812050131p2e9ac761n1c76575d3a3f5792@mail.gmail.com> <Pine.GSO.4.64.0812050956110.22402@zeno.ucsd.edu> <493974DE.1050802@math.missouri.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 5 Dec 2008, Stephen Montgomery-Smith wrote:

> Nate Eldredge wrote:
>
>> int bangbang(int x) { return !!x; }
>> int ternary(int x) { return x ? 1 : 0; }
>
> Stylewise, I prefer
>
> int notzero(int x) { return x!=0; }

icc -O0 compiles notzero the same as bangbang (better than ternary).  tcc 
produces better code for notzero than the other two.  Sun cc without 
optimization produces slightly better code for notzero than the other two 
(one jump instead of two).  For everything else all three produce 
equivalent code.

`x && 1' and `x || 0' are some other possibilities.

Anyway, maybe there is something more useful we could all be doing. :)

-- 

Nate Eldredge
neldredge@math.ucsd.edu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0812051105250.22402>