From owner-svn-src-head@FreeBSD.ORG Tue Nov 22 14:20:22 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 643D5106564A; Tue, 22 Nov 2011 14:20:22 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theravensnest.org [109.169.23.128]) by mx1.freebsd.org (Postfix) with ESMTP id 016918FC0A; Tue, 22 Nov 2011 14:20:21 +0000 (UTC) Received: from [192.168.0.2] (cpc2-cwma5-0-0-cust875.7-3.cable.virginmedia.com [86.11.39.108]) (authenticated bits=0) by theravensnest.org (8.14.4/8.14.4) with ESMTP id pAMEKKsT025300 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Tue, 22 Nov 2011 14:20:20 GMT (envelope-from theraven@FreeBSD.org) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: David Chisnall In-Reply-To: <20111122210422.E8674@besplex.bde.org> Date: Tue, 22 Nov 2011 14:20:15 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <8B1C6EE4-A351-44A6-AC8A-DC53779CD380@FreeBSD.org> References: <201111220250.pAM2oPWC070856@svn.freebsd.org> <20111122210422.E8674@besplex.bde.org> To: Bruce Evans X-Mailer: Apple Mail (2.1251.1) Cc: svn-src-head@FreeBSD.org, mdf@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler Subject: Re: svn commit: r227812 - head/lib/libc/string X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2011 14:20:22 -0000 On 22 Nov 2011, at 11:21, Bruce Evans wrote: > If this optimization were any good, then the compiler would already do > it. In fact, gcc-4.2.1 already does it -- the reverse of it -- it = rewrites: >=20 > "if ((i =3D=3D 0) | (j =3D=3D 0)) return; test();" >=20 > into: >=20 > "if (i =3D=3D 0 || j =3D=3D 0) return; test();" In general, I prefer | in cases where execution order does not matter = because it frees the compiler up to insert branches or not, depending on = which is more efficient for the target. =20 In this case, either | or || is fine, because neither reads any memory = or has side effects so | and || are equivalent to the compiler, but the = use of | tells a human reading the code that the order is unimportant. =20= David=