Patchwork [2/5] target-s390: Simplify op_clc

login
register
mail settings
Submitter Richard Henderson
Date Dec. 11, 2013, 7:30 p.m.
Message ID <1386790247-14267-3-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/300311/
State New
Headers show

Comments

Richard Henderson - Dec. 11, 2013, 7:30 p.m.
New opcodes can unify 4 different code paths.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-s390x/translate.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

Patch

diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index 8fc8259..8f8567e 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -1750,34 +1750,22 @@  static ExitStatus op_cksm(DisasContext *s, DisasOps *o)
 static ExitStatus op_clc(DisasContext *s, DisasOps *o)
 {
     int l = get_field(s->fields, l1);
-    TCGv_i32 vl;
 
-    switch (l + 1) {
-    case 1:
-        tcg_gen_qemu_ld_i64(cc_src, o->addr1, get_mem_index(s), MO_UB);
-        tcg_gen_qemu_ld_i64(cc_dst, o->in2, get_mem_index(s), MO_UB);
-        break;
-    case 2:
-        tcg_gen_qemu_ld_i64(cc_src, o->addr1, get_mem_index(s), MO_BEUW);
-        tcg_gen_qemu_ld_i64(cc_dst, o->in2, get_mem_index(s), MO_BEUW);
-        break;
-    case 4:
-        tcg_gen_qemu_ld_i64(cc_src, o->addr1, get_mem_index(s), MO_BEUL);
-        tcg_gen_qemu_ld_i64(cc_dst, o->in2, get_mem_index(s), MO_BEUL);
-        break;
-    case 8:
-        tcg_gen_qemu_ld_i64(cc_src, o->addr1, get_mem_index(s), MO_BEQ);
-        tcg_gen_qemu_ld_i64(cc_dst, o->in2, get_mem_index(s), MO_BEQ);
-        break;
-    default:
+    if (l + 1 <= 8) {
+        TCGMemOp mop = MO_BE + ctz32(l + 1);
+
+        tcg_gen_qemu_ld_i64(cc_src, o->addr1, get_mem_index(s), mop);
+        tcg_gen_qemu_ld_i64(cc_dst, o->in2, get_mem_index(s), mop);
+        gen_op_update2_cc_i64(s, CC_OP_LTUGTU_64, cc_src, cc_dst);
+    } else {
+        TCGv_i32 vl;
+
         potential_page_fault(s);
         vl = tcg_const_i32(l);
         gen_helper_clc(cc_op, cpu_env, vl, o->addr1, o->in2);
         tcg_temp_free_i32(vl);
         set_cc_static(s);
-        return NO_EXIT;
     }
-    gen_op_update2_cc_i64(s, CC_OP_LTUGTU_64, cc_src, cc_dst);
     return NO_EXIT;
 }