s390: Add spechelper for s390_calculate_cc.
git-svn-id: svn://svn.valgrind.org/vex/trunk@2762 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/guest_s390_helpers.c b/priv/guest_s390_helpers.c
index f270929..610a57c 100644
--- a/priv/guest_s390_helpers.c
+++ b/priv/guest_s390_helpers.c
@@ -2357,10 +2357,39 @@
mkU64(0)));
}
-missed:
- ;
+ goto missed;
}
+ /* --------- Specialising "s390_calculate_cond" --------- */
+
+ if (vex_streq(function_name, "s390_calculate_cc")) {
+ IRExpr *cc_op_expr, *cc_dep1;
+ ULong cc_op;
+
+ vassert(arity == 4);
+
+ cc_op_expr = args[0];
+
+ /* The necessary requirement for all optimizations here is that
+ cc_op is constant. So check that upfront. */
+ if (! isC64(cc_op_expr)) return NULL;
+
+ cc_op = cc_op_expr->Iex.Const.con->Ico.U64;
+ cc_dep1 = args[1];
+
+ if (cc_op == S390_CC_OP_BITWISE) {
+ return unop(Iop_1Uto32,
+ binop(Iop_CmpNE64, cc_dep1, mkU64(0)));
+ }
+
+ if (cc_op == S390_CC_OP_SET) {
+ return unop(Iop_64to32, cc_dep1);
+ }
+
+ goto missed;
+ }
+
+missed:
return NULL;
}