From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9FOB-0000rg-9S for qemu-devel@nongnu.org; Fri, 31 Jan 2014 09:48:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9FO5-0007N3-14 for qemu-devel@nongnu.org; Fri, 31 Jan 2014 09:48:14 -0500 Received: from mail-qc0-x230.google.com ([2607:f8b0:400d:c01::230]:63379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9FO4-0007Mt-Ma for qemu-devel@nongnu.org; Fri, 31 Jan 2014 09:48:08 -0500 Received: by mail-qc0-f176.google.com with SMTP id e16so7174438qcx.35 for ; Fri, 31 Jan 2014 06:48:07 -0800 (PST) Sender: Richard Henderson From: Richard Henderson Date: Fri, 31 Jan 2014 08:47:03 -0600 Message-Id: <1391179623-13626-9-git-send-email-rth@twiddle.net> In-Reply-To: <1391179623-13626-1-git-send-email-rth@twiddle.net> References: <1391179623-13626-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 8/8] tcg/optimize: Add more identity simplifications List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aurelien@aurel32.net Recognize 0 operand to andc, and -1 operands to and, orc, eqv. Signed-off-by: Richard Henderson --- tcg/optimize.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index a703f8c..8d7100e 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -716,7 +716,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, break; } - /* Simplify expression for "op r, a, 0 => mov r, a" cases */ + /* Simplify expression for "op r, a, const => mov r, a" cases */ switch (op) { CASE_OP_32_64(add): CASE_OP_32_64(sub): @@ -727,23 +727,32 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(rotr): CASE_OP_32_64(or): CASE_OP_32_64(xor): - if (temps[args[1]].state == TCG_TEMP_CONST) { - /* Proceed with possible constant folding. */ - break; - } - if (temps[args[2]].state == TCG_TEMP_CONST + CASE_OP_32_64(andc): + if (temps[args[1]].state != TCG_TEMP_CONST + && temps[args[2]].state == TCG_TEMP_CONST && temps[args[2]].val == 0) { - if (temps_are_copies(args[0], args[1])) { - s->gen_opc_buf[op_index] = INDEX_op_nop; - } else { - s->gen_opc_buf[op_index] = op_to_mov(op); - tcg_opt_gen_mov(s, gen_args, args[0], args[1]); - gen_args += 2; - } - args += 3; - continue; + goto do_mov3; } break; + CASE_OP_32_64(and): + CASE_OP_32_64(orc): + CASE_OP_32_64(eqv): + if (temps[args[1]].state != TCG_TEMP_CONST + && temps[args[2]].state == TCG_TEMP_CONST + && temps[args[2]].val == -1) { + goto do_mov3; + } + break; + do_mov3: + if (temps_are_copies(args[0], args[1])) { + s->gen_opc_buf[op_index] = INDEX_op_nop; + } else { + s->gen_opc_buf[op_index] = op_to_mov(op); + tcg_opt_gen_mov(s, gen_args, args[0], args[1]); + gen_args += 2; + } + args += 3; + continue; default: break; } -- 1.8.5.3