From: H. Peter Anvin Date: Fri, 29 Apr 2011 16:24:08 GMT Subject: Re: [PATCH] git gc: Speed it up by 18% via faster hash comparisons Message-ID: <4DBAE628.4080501@zytor.com> In-Reply-To: On 04/29/2011 12:05 AM, Alex Riesen wrote: > > Can one take advantage of common expression optimization here? > Like this: > > + if (*sha1 - *sha2) > + return *sha1 - *sha2; > Or even clue the compiler in explicitly: delta = *sha1 - *sha2; if (delta) return delta; For newer x86-specific optimization there are a bunch of newer SSE instructions which can be used to do bulk compares which may be faster if optimized for the fixed length compare; of course it requires a new enough processor. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.