diff mbox

[3/7] target-alpha: Use setcond/movcond in integer compares and cmoves.

Message ID 70e763bd5b6fed7076f986f03a6fce21124d05fb.1261012798.git.rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Dec. 16, 2009, 12:36 a.m. UTC
Limited usage of setcond/movcond to enable testing in the code generator.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-alpha/translate.c |   66 +++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 35 deletions(-)
diff mbox

Patch

diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index 7b6ff2a..f51d4ef 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -391,33 +391,33 @@  static void gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp)
 static inline void gen_cmov(TCGCond inv_cond, int ra, int rb, int rc,
                             int islit, uint8_t lit, int mask)
 {
-    int l1;
+    TCGv va, vb, zero;
 
     if (unlikely(rc == 31))
         return;
 
-    l1 = gen_new_label();
-
-    if (ra != 31) {
-        if (mask) {
-            TCGv tmp = tcg_temp_new();
-            tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);
-            tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1);
-            tcg_temp_free(tmp);
-        } else
-            tcg_gen_brcondi_i64(inv_cond, cpu_ir[ra], 0, l1);
+    zero = tcg_const_i64(0);
+    if (ra == 31) {
+        va = zero;
+    } else if (mask) {
+        va = tcg_temp_new();
+        tcg_gen_andi_i64(va, cpu_ir[ra], 1);
     } else {
-        /* Very uncommon case - Do not bother to optimize.  */
-        TCGv tmp = tcg_const_i64(0);
-        tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1);
-        tcg_temp_free(tmp);
+        va = cpu_ir[ra];
     }
 
     if (islit)
-        tcg_gen_movi_i64(cpu_ir[rc], lit);
+        vb = tcg_const_i64(lit);
     else
-        tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
-    gen_set_label(l1);
+        vb = cpu_ir[rb];
+
+    tcg_gen_movcond_i64(inv_cond, cpu_ir[rc], va, zero, cpu_ir[rc], vb);
+
+    tcg_temp_free(zero);
+    if (mask && ra != 31)
+        tcg_temp_free(va);
+    if (islit)
+        tcg_temp_free(vb);
 }
 
 static void gen_fcmov(TCGCond inv_cond, int ra, int rb, int rc)
@@ -873,30 +873,26 @@  MVIOP2(unpkbw)
 static inline void gen_cmp(TCGCond cond, int ra, int rb, int rc, int islit,
                            uint8_t lit)
 {
-    int l1, l2;
-    TCGv tmp;
+    TCGv va, vb;
 
     if (unlikely(rc == 31))
         return;
 
-    l1 = gen_new_label();
-    l2 = gen_new_label();
-
-    if (ra != 31) {
-        tmp = tcg_temp_new();
-        tcg_gen_mov_i64(tmp, cpu_ir[ra]);
-    } else
-        tmp = tcg_const_i64(0);
+    if (ra == 31)
+        va = tcg_const_i64(0);
+    else
+        va = cpu_ir[ra];
     if (islit)
-        tcg_gen_brcondi_i64(cond, tmp, lit, l1);
+        vb = tcg_const_i64(lit);
     else
-        tcg_gen_brcond_i64(cond, tmp, cpu_ir[rb], l1);
+        vb = cpu_ir[rb];
 
-    tcg_gen_movi_i64(cpu_ir[rc], 0);
-    tcg_gen_br(l2);
-    gen_set_label(l1);
-    tcg_gen_movi_i64(cpu_ir[rc], 1);
-    gen_set_label(l2);
+    tcg_gen_setcond_i64(cond, cpu_ir[rc], va, vb);
+
+    if (ra == 31)
+        tcg_temp_free(va);
+    if (islit)
+        tcg_temp_free(vb);
 }
 
 static inline int translate_one(DisasContext *ctx, uint32_t insn)