Received: from eggs.gnu.org ([208.118.235.92]:50178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLc3c-0003ml-LP for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:49:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLc30-0004DK-Mp for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:49:20 -0400 Received: from hall.aurel32.net ([88.191.126.93]:39193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLc30-0004Ce-Gg for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:48:42 -0400 Date: Tue, 9 Oct 2012 17:48:35 +0200 From: Aurelien Jarno Message-ID: <20121009154835.GF14078@ohm.aurel32.net> References: <1349202750-16815-1-git-send-email-rth@twiddle.net> <1349202750-16815-4-git-send-email-rth@twiddle.net> <20121009151622.GD14078@ohm.aurel32.net> <50744363.7080108@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <50744363.7080108@twiddle.net> Subject: Re: [Qemu-devel] [PATCH 03/10] tcg: Swap commutative double-word comparisons List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org On Tue, Oct 09, 2012 at 08:31:47AM -0700, Richard Henderson wrote: > On 10/09/2012 08:16 AM, Aurelien Jarno wrote: > >> > +static bool swap_commutative2(TCGArg *p1, TCGArg *p2) > >> > +{ > >> > + int sum = 0; > >> > + sum += temps[p1[0]].state == TCG_TEMP_CONST; > >> > + sum += temps[p1[1]].state == TCG_TEMP_CONST; > >> > + sum -= temps[p2[0]].state == TCG_TEMP_CONST; > >> > + sum -= temps[p2[1]].state == TCG_TEMP_CONST; > >> > + if (sum > 0) { > ... > > Same comment are for the swap_commutative() patch, otherwise: > > While I don't have an explicit test case for swap_commutative2 like > I do for swap_commutative, think about how many conditionals you'd > have to use to write this without using SUM: > > if (((temps[p1[0]].state == TCG_TEMP_CONST // if both p1 are const > && temps[p1[1]].state == TCG_TEMP_CONST > && !(temps[p2[0]].state == TCG_TEMP_CONST // ... and not both p2 are const > && temps[p2[1]].state == TCG_TEMP_CONST)) > || ((temps[p1[0]].state == TCG_TEMP_CONST // if either p1 are const > || temps[p1[1]].state == TCG_TEMP_CONST) > && !temps[p2[0]].state == TCG_TEMP_CONST // ... and neither p2 are const > && !temps[p2[1]].state == TCG_TEMP_CONST)) > > I don't see how that can possibly be easier to understand. > > For that one I agree. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net