Skip to contentSkip to conversation

[6198] CRIS: Slight performance improvement for flag evaluation.

Qemu-devel Edgar E. Iglesias 1 participant 1 message Jan 7, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6198

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6198
Author:   edgar_igl
Date:     2009-01-07 12:25:15 +0000 (Wed, 07 Jan 2009)

Log Message:
-----------
CRIS: Slight performance improvement for flag evaluation.

Translate sub and cmp ops separately when evaluating flags to avoid checking for them at runtime.

Modified Paths:
--------------
trunk/target-cris/helper.h
trunk/target-cris/op_helper.c
trunk/target-cris/translate.c

Modified: trunk/target-cris/helper.h
===================================================================

target-cris/helper.h +1 -0
@@ -14,6 +14,7 @@
 DEF_HELPER_0(evaluate_flags_mulu, void)
 DEF_HELPER_0(evaluate_flags_mcp, void)
 DEF_HELPER_0(evaluate_flags_alu_4, void)
+DEF_HELPER_0(evaluate_flags_sub_4, void)
 DEF_HELPER_0(evaluate_flags_move_4, void)
 DEF_HELPER_0(evaluate_flags_move_2, void)
 DEF_HELPER_0(evaluate_flags, void)

Modified: trunk/target-cris/op_helper.c
===================================================================

target-cris/op_helper.c +57 -51

169 lines not on this page · raw message

Modified: trunk/target-cris/translate.c
===================================================================

target-cris/translate.c +18 -8
@@ -728,8 +728,15 @@
 			case CC_OP_FLAGS:
 				/* live.  */
 				break;
+			case CC_OP_SUB:
+			case CC_OP_CMP:
+				if (dc->cc_size == 4)
+					gen_helper_evaluate_flags_sub_4();
+				else
+					gen_helper_evaluate_flags();
+
+				break;
 			default:
-			{
 				switch (dc->cc_size)
 				{
 					case 4:
@@ -739,7 +746,6 @@
 						gen_helper_evaluate_flags();
 						break;
 				}
-			}
 			break;
 		}
 		if (dc->flagx_known) {
@@ -821,13 +827,8 @@
 /* Update cc after executing ALU op. needs the result.  */
 static inline void cris_update_result(DisasContext *dc, TCGv res)
 {
-	if (dc->update_cc) {
-		if (dc->cc_size == 4 && 
-		    (dc->cc_op == CC_OP_SUB
-		     || dc->cc_op == CC_OP_ADD))
-			return;
+	if (dc->update_cc)
 		tcg_gen_mov_tl(cc_result, res);
-	}
 }
 
 /* Returns one if the write back stage should execute.  */
@@ -1890,6 +1891,10 @@
 	DIS(fprintf (logfile, "addc $r%u, $r%u\n",
 		    dc->op1, dc->op2));
 	cris_evaluate_flags(dc);
+	/* Set for this insn.  */
+	dc->flagx_known = 1;
+	dc->flags_x = X_FLAG;
+
 	cris_cc_mask(dc, CC_MASK_NZVC);
 	cris_alu(dc, CC_OP_ADDC,
 		 cpu_R[dc->op2], cpu_R[dc->op2], cpu_R[dc->op1], 4);
@@ -2615,6 +2620,11 @@
 		    dc->op2));
 
 	cris_evaluate_flags(dc);
+
+	/* Set for this insn.  */
+	dc->flagx_known = 1;
+	dc->flags_x = X_FLAG;
+
 	cris_alu_m_alloc_temps(t);
 	insn_len = dec_prep_alu_m(dc, 0, 4, t[0], t[1]);
 	cris_cc_mask(dc, CC_MASK_NZVC);