Date: Tue, 22 Nov 2011 14:20:15 +0000 From: David Chisnall <theraven@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@FreeBSD.org, mdf@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler <eadler@FreeBSD.org> Subject: Re: svn commit: r227812 - head/lib/libc/string Message-ID: <8B1C6EE4-A351-44A6-AC8A-DC53779CD380@FreeBSD.org> In-Reply-To: <20111122210422.E8674@besplex.bde.org> References: <201111220250.pAM2oPWC070856@svn.freebsd.org> <CAMBSHm8HfW-XTSk9zQda4vDmbrzyEG_vnydb5JZyHaNh2rF4gw@mail.gmail.com> <20111122210422.E8674@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8B1C6EE4-A351-44A6-AC8A-DC53779CD380>