From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THHrS-0008Si-C8 for qemu-devel@nongnu.org; Thu, 27 Sep 2012 13:26:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THHrN-0005tk-7r for qemu-devel@nongnu.org; Thu, 27 Sep 2012 13:26:54 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:57826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THHrN-0005tX-1Y for qemu-devel@nongnu.org; Thu, 27 Sep 2012 13:26:49 -0400 Received: by pbbrp2 with SMTP id rp2so3914753pbb.4 for ; Thu, 27 Sep 2012 10:26:48 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Thu, 27 Sep 2012 10:19:53 -0700 Message-Id: <1348766397-20731-4-git-send-email-rth@twiddle.net> In-Reply-To: <1348766397-20731-1-git-send-email-rth@twiddle.net> References: <1348766397-20731-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 3/7] tcg: Swap commutative double-word comparisons List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/optimize.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tcg/optimize.c b/tcg/optimize.c index 004c336..d39926e 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -397,6 +397,22 @@ static bool swap_commutative(TCGArg dest, TCGArg *p1, TCGArg *p2) return false; } +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) { + TCGArg t; + t = p1[0], p1[0] = p2[0], p2[0] = t; + t = p1[1], p1[1] = p2[1], p2[1] = t; + return true; + } + return false; +} + /* Propagate constants and copies, fold constant expressions. */ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, TCGArg *args, TCGOpDef *tcg_op_defs) @@ -475,6 +491,16 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, swap_commutative(args[0], &args[2], &args[4]); swap_commutative(args[1], &args[3], &args[5]); break; + case INDEX_op_brcond2_i32: + if (swap_commutative2(&args[0], &args[2])) { + args[4] = tcg_swap_cond(args[4]); + } + break; + case INDEX_op_setcond2_i32: + if (swap_commutative2(&args[1], &args[3])) { + args[5] = tcg_swap_cond(args[5]); + } + break; default: break; } -- 1.7.11.4