Received: from eggs.gnu.org ([208.118.235.92]:59343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGFWj-0005aJ-9O for qemu-devel@nongnu.org; Mon, 24 Sep 2012 16:45:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGFWi-00041W-61 for qemu-devel@nongnu.org; Mon, 24 Sep 2012 16:45:13 -0400 Received: from mail-qc0-f173.google.com ([209.85.216.173]:53652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGFWi-000418-1X for qemu-devel@nongnu.org; Mon, 24 Sep 2012 16:45:12 -0400 Received: by qcab12 with SMTP id b12so1440685qca.4 for ; Mon, 24 Sep 2012 13:45:11 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Mon, 24 Sep 2012 13:44:59 -0700 Message-Id: <1348519500-16488-2-git-send-email-rth@twiddle.net> In-Reply-To: <1348519500-16488-1-git-send-email-rth@twiddle.net> References: <1348519500-16488-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 1/2] tcg: Streamline movcond_i64 using 32-bit arithmetic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aurelien@aurel32.net Avoiding 64-bit arithmetic (outside of the compare) reduces the generated op count from 15 to 12, and the generated code size on i686 from 105 to 88 bytes. Signed-off-by: Richard Henderson --- tcg/tcg-op.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 6d28f82..c32646e 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -2141,6 +2141,25 @@ static inline void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, TCGv_i64 c1, TCGv_i64 c2, TCGv_i64 v1, TCGv_i64 v2) { +#if TCG_TARGET_REG_BITS == 32 + TCGv_i32 t0 = tcg_temp_new_i32(); + TCGv_i32 t1 = tcg_temp_new_i32(); + tcg_gen_op6i_i32(INDEX_op_setcond2_i32, t0, + TCGV_LOW(c1), TCGV_HIGH(c1), + TCGV_LOW(c2), TCGV_HIGH(c2), cond); + tcg_gen_neg_i32(t0, t0); + + tcg_gen_and_i32(t1, TCGV_LOW(v1), t0); + tcg_gen_andc_i32(TCGV_LOW(ret), TCGV_LOW(v2), t0); + tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(ret), t1); + + tcg_gen_and_i32(t1, TCGV_HIGH(v1), t0); + tcg_gen_andc_i32(TCGV_HIGH(ret), TCGV_HIGH(v2), t0); + tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), t1); + + tcg_temp_free_i32(t0); + tcg_temp_free_i32(t1); +#else if (TCG_TARGET_HAS_movcond_i64) { tcg_gen_op6i_i64(INDEX_op_movcond_i64, ret, c1, c2, v1, v2, cond); } else { @@ -2154,6 +2173,7 @@ static inline void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); } +#endif } /***************************************/ -- 1.7.11.4