From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLbnu-0001mQ-9y for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLbmh-0007zw-1w for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:33:06 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:43264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLbmg-0007zU-7h for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:31:50 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so5282194pad.4 for ; Tue, 09 Oct 2012 08:31:49 -0700 (PDT) Sender: Richard Henderson Message-ID: <50744363.7080108@twiddle.net> Date: Tue, 09 Oct 2012 08:31:47 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1349202750-16815-1-git-send-email-rth@twiddle.net> <1349202750-16815-4-git-send-email-rth@twiddle.net> <20121009151622.GD14078@ohm.aurel32.net> In-Reply-To: <20121009151622.GD14078@ohm.aurel32.net> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit 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: Aurelien Jarno Cc: qemu-devel@nongnu.org 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. r~