Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KytMu-0001d1-Kn for qemu-devel@nongnu.org; Sat, 08 Nov 2008 14:21:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KytMt-0001c6-KO for qemu-devel@nongnu.org; Sat, 08 Nov 2008 14:21:11 -0500 Received: from [199.232.76.173] (port=53181 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KytMt-0001bl-85 for qemu-devel@nongnu.org; Sat, 08 Nov 2008 14:21:11 -0500 Received: from hall.aurel32.net ([88.191.82.174]:35571) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KytMs-0005Cm-MJ for qemu-devel@nongnu.org; Sat, 08 Nov 2008 14:21:11 -0500 Date: Sat, 8 Nov 2008 20:21:08 +0100 From: Aurelien Jarno Message-ID: <20081108192108.GJ15084@volta.aurel32.net> References: <20081108191604.GA20748@volta.aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20081108191604.GA20748@volta.aurel32.net> Subject: [Qemu-devel] [PATCH v2 09/11] target-mips: optimize movc*() Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Optimize code generation in gen_movc*(): - Temp variables are valid up to and *including* the brcond instruction. Use them instead of temp local variables. - Avoid using temporary variables to transfer values. - Access fpu_fcr31 directly in gen_movcf_ps(). Signed-off-by: Aurelien Jarno --- target-mips/translate.c | 81 +++++++++++++++++++---------------------------- 1 files changed, 33 insertions(+), 48 deletions(-) diff --git a/target-mips/translate.c b/target-mips/translate.c index 0afcb05..2be15f6 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -5930,8 +5930,7 @@ static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf) uint32_t ccbit; TCGCond cond; TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL); - TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL); - TCGv r_tmp = tcg_temp_local_new(TCG_TYPE_I32); + TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32); if (cc) ccbit = 1 << (24 + cc); @@ -5943,14 +5942,9 @@ static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf) cond = TCG_COND_NE; gen_load_gpr(t0, rd); - gen_load_gpr(t1, rs); tcg_gen_andi_i32(r_tmp, fpu_fcr31, ccbit); tcg_gen_brcondi_i32(cond, r_tmp, 0, l1); - tcg_temp_free(r_tmp); - - tcg_gen_mov_tl(t0, t1); - tcg_temp_free(t1); - + gen_load_gpr(t0, rs); gen_set_label(l1); gen_store_gpr(t0, rd); tcg_temp_free(t0); @@ -5960,9 +5954,8 @@ static inline void gen_movcf_s (int fs, int fd, int cc, int tf) { uint32_t ccbit; int cond; - TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32); + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32); - TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32); int l1 = gen_new_label(); if (cc) @@ -5975,25 +5968,21 @@ static inline void gen_movcf_s (int fs, int fd, int cc, int tf) else cond = TCG_COND_NE; - gen_load_fpr32(fp0, fs); - gen_load_fpr32(fp1, fd); + gen_load_fpr32(fp0, fd); tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit); tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1); - tcg_gen_mov_i32(fp1, fp0); - tcg_temp_free(fp0); + gen_load_fpr32(fp0, fs); gen_set_label(l1); - tcg_temp_free(r_tmp1); - gen_store_fpr32(fp1, fd); - tcg_temp_free(fp1); + gen_store_fpr32(fp0, fd); + tcg_temp_free(fp0); } static inline void gen_movcf_d (DisasContext *ctx, int fs, int fd, int cc, int tf) { uint32_t ccbit; int cond; - TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32); + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I64); - TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I64); int l1 = gen_new_label(); if (cc) @@ -6006,57 +5995,53 @@ static inline void gen_movcf_d (DisasContext *ctx, int fs, int fd, int cc, int t else cond = TCG_COND_NE; - gen_load_fpr64(ctx, fp0, fs); - gen_load_fpr64(ctx, fp1, fd); + gen_load_fpr64(ctx, fp0, fd); tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit); tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1); - tcg_gen_mov_i64(fp1, fp0); - tcg_temp_free(fp0); + gen_load_fpr64(ctx, fp0, fs); gen_set_label(l1); - tcg_temp_free(r_tmp1); - gen_store_fpr64(ctx, fp1, fd); - tcg_temp_free(fp1); + gen_store_fpr64(ctx, fp0, fd); + tcg_temp_free(fp0); } static inline void gen_movcf_ps (int fs, int fd, int cc, int tf) { + uint32_t ccbit1, ccbit2; int cond; TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32); - TCGv r_tmp2 = tcg_temp_local_new(TCG_TYPE_I32); TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32); - TCGv fph0 = tcg_temp_local_new(TCG_TYPE_I32); - TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32); - TCGv fph1 = tcg_temp_local_new(TCG_TYPE_I32); int l1 = gen_new_label(); int l2 = gen_new_label(); + if (cc) { + ccbit1 = 1 << (24 + cc); + ccbit2 = 1 << (25 + cc); + } else { + ccbit1 = 1 << 23; + ccbit2 = 1 << 25; + } + if (tf) cond = TCG_COND_EQ; else cond = TCG_COND_NE; + gen_load_fpr32(fp0, fd); + tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit1); + tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1); gen_load_fpr32(fp0, fs); - gen_load_fpr32h(fph0, fs); - gen_load_fpr32(fp1, fd); - gen_load_fpr32h(fph1, fd); - get_fp_cond(r_tmp1); - tcg_gen_shri_i32(r_tmp1, r_tmp1, cc); - tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x1); - tcg_gen_brcondi_i32(cond, r_tmp2, 0, l1); - tcg_gen_mov_i32(fp1, fp0); - tcg_temp_free(fp0); gen_set_label(l1); - tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x2); - tcg_gen_brcondi_i32(cond, r_tmp2, 0, l2); - tcg_gen_mov_i32(fph1, fph0); - tcg_temp_free(fph0); + gen_store_fpr32(fp0, fd); + + gen_load_fpr32h(fp0, fd); + tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit2); + tcg_gen_brcondi_i32(cond, r_tmp1, 0, l2); + gen_load_fpr32h(fp0, fs); gen_set_label(l2); + gen_store_fpr32h(fp0, fd); + tcg_temp_free(r_tmp1); - tcg_temp_free(r_tmp2); - gen_store_fpr32(fp1, fd); - gen_store_fpr32h(fph1, fd); - tcg_temp_free(fp1); - tcg_temp_free(fph1); + tcg_temp_free(fp0); } -- 1.5.6.5 -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net