From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 5 19:12:28 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 616811065676 for ; Fri, 5 Dec 2008 19:12:28 +0000 (UTC) (envelope-from neldredge@math.ucsd.edu) Received: from euclid.ucsd.edu (euclid.ucsd.edu [132.239.145.52]) by mx1.freebsd.org (Postfix) with ESMTP id 387EE8FC23 for ; Fri, 5 Dec 2008 19:12:27 +0000 (UTC) (envelope-from neldredge@math.ucsd.edu) Received: from zeno.ucsd.edu (zeno.ucsd.edu [132.239.145.22]) by euclid.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id mB5JCR601636; Fri, 5 Dec 2008 11:12:27 -0800 (PST) Received: from localhost (neldredg@localhost) by zeno.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id mB5JCRc03084; Fri, 5 Dec 2008 11:12:27 -0800 (PST) X-Authentication-Warning: zeno.ucsd.edu: neldredg owned process doing -bs Date: Fri, 5 Dec 2008 11:12:26 -0800 (PST) From: Nate Eldredge X-X-Sender: neldredg@zeno.ucsd.edu To: Stephen Montgomery-Smith In-Reply-To: <493974DE.1050802@math.missouri.edu> Message-ID: References: <7d6fde3d0812040324y3bf0901cy1f4a6d961362c314@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> <493974DE.1050802@math.missouri.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Nate Eldredge , Garrett Cooper , Christoph Mallon , FreeBSD Hackers , Maksim Yevmenkin Subject: Re: RFC: small syscons and kbd patch X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2008 19:12:28 -0000 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