From 6c1cb1a0128b00858b973ef9344e12d6ddbaaf57 Mon Sep 17 00:00:00 2001 From: Andreas Arnez Date: Thu, 25 Mar 2021 18:48:07 +0100 Subject: [PATCH] s390x: Add support for emitting "vector or with complement" In the instruction selector, look out for IR expressions that fit "vector or with complement (VOC)". Emit when applicable. This slighly reduces the generated code sometimes, such as for certain vector string instructions, where such expressions occur quite frequently. --- VEX/priv/host_s390_defs.c | 12 ++++++++++++ VEX/priv/host_s390_defs.h | 1 + VEX/priv/host_s390_isel.c | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index c764d6ef92..239d9d2997 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -5907,6 +5907,15 @@ s390_emit_VO(UChar *p, UChar v1, UChar v2, UChar v3) return emit_VRR_VVV(p, 0xE7000000006aULL, v1, v2, v3); } +static UChar * +s390_emit_VOC(UChar *p, UChar v1, UChar v2, UChar v3) +{ + if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) + s390_disasm(ENC4(MNM, VR, VR, VR), "voc", v1, v2, v3); + + return emit_VRR_VVV(p, 0xE7000000006fULL, v1, v2, v3); +} + static UChar * s390_emit_VX(UChar *p, UChar v1, UChar v2, UChar v3) { @@ -8312,6 +8321,7 @@ s390_insn_as_string(const s390_insn *insn) case S390_VEC_PACK_SATURU: op = "v-vpacksaturu"; break; case S390_VEC_COMPARE_EQUAL: op = "v-vcmpeq"; break; case S390_VEC_OR: op = "v-vor"; break; + case S390_VEC_ORC: op = "v-vorc"; break; case S390_VEC_XOR: op = "v-vxor"; break; case S390_VEC_AND: op = "v-vand"; break; case S390_VEC_MERGEL: op = "v-vmergel"; break; @@ -11609,6 +11619,8 @@ s390_insn_vec_binop_emit(UChar *buf, const s390_insn *insn) return s390_emit_VCEQ(buf, v1, v2, v3, s390_getM_from_size(size)); case S390_VEC_OR: return s390_emit_VO(buf, v1, v2, v3); + case S390_VEC_ORC: + return s390_emit_VOC(buf, v1, v2, v3); case S390_VEC_XOR: return s390_emit_VX(buf, v1, v2, v3); case S390_VEC_AND: diff --git a/VEX/priv/host_s390_defs.h b/VEX/priv/host_s390_defs.h index 063fd38005..dc116106ef 100644 --- a/VEX/priv/host_s390_defs.h +++ b/VEX/priv/host_s390_defs.h @@ -366,6 +366,7 @@ typedef enum { S390_VEC_PACK_SATURU, S390_VEC_COMPARE_EQUAL, S390_VEC_OR, + S390_VEC_ORC, S390_VEC_XOR, S390_VEC_AND, S390_VEC_MERGEL, diff --git a/VEX/priv/host_s390_isel.c b/VEX/priv/host_s390_isel.c index 9681225961..53d76fe8a0 100644 --- a/VEX/priv/host_s390_isel.c +++ b/VEX/priv/host_s390_isel.c @@ -4102,6 +4102,15 @@ s390_isel_vec_expr_wrk(ISelEnv *env, IRExpr *expr) case Iop_OrV128: size = 16; vec_binop = S390_VEC_OR; + if (arg1->tag == Iex_Unop && arg1->Iex.Unop.op == Iop_NotV128) { + IRExpr* orig_arg1 = arg1; + arg1 = arg2; + arg2 = orig_arg1->Iex.Unop.arg; + vec_binop = S390_VEC_ORC; + } else if (arg2->tag == Iex_Unop && arg2->Iex.Unop.op == Iop_NotV128) { + arg2 = arg2->Iex.Unop.arg; + vec_binop = S390_VEC_ORC; + } goto Iop_VV_wrk; case Iop_XorV128: -- 2.47.2