From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEQRq-0003rE-US for qemu-devel@nongnu.org; Wed, 19 Sep 2012 16:00:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEQRg-0002CE-R9 for qemu-devel@nongnu.org; Wed, 19 Sep 2012 16:00:38 -0400 Received: from hall.aurel32.net ([88.191.126.93]:52045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEQRg-0002AG-LD for qemu-devel@nongnu.org; Wed, 19 Sep 2012 16:00:28 -0400 From: Aurelien Jarno Date: Wed, 19 Sep 2012 22:00:22 +0200 Message-Id: <1348084823-18277-9-git-send-email-aurelien@aurel32.net> In-Reply-To: <1348084823-18277-1-git-send-email-aurelien@aurel32.net> References: <1348084823-18277-1-git-send-email-aurelien@aurel32.net> Subject: [Qemu-devel] [PATCH 8/9] tcg/optimize: prefer the "op a, a, b" form for commutative ops List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Aurelien Jarno The "op a, a, b" form is better handled on non-RISC host than the "op a, b, a" form, so swap the arguments to this form when possible, and when b is not a constant. This reduces the number of generated instructions by a tiny bit. Signed-off-by: Aurelien Jarno --- tcg/optimize.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 6e2a37d..3495b7a 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -432,7 +432,10 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(eqv): CASE_OP_32_64(nand): CASE_OP_32_64(nor): - if (temps[args[1]].state == TCG_TEMP_CONST) { + /* Prefer the constant in second argument, and then the form + op a, a, b, which is better handled on non-RISC hosts. */ + if (temps[args[1]].state == TCG_TEMP_CONST || (args[0] == args[2] + && temps[args[2]].state != TCG_TEMP_CONST)) { tmp = args[1]; args[1] = args[2]; args[2] = tmp; -- 1.7.10.4