Message ID | 20190411100836.646-6-david@redhat.com |
---|---|
State | New |
Headers | show |
Series | s390x/tcg: Vector Instruction Support Part 2 | expand |
On 4/11/19 12:08 AM, David Hildenbrand wrote: > +static DisasJumpType op_vaccc(DisasContext *s, DisasOps *o) > +{ > + if (get_field(s->fields, m5) != ES_128) { > + gen_program_exception(s, PGM_SPECIFICATION); > + return DISAS_NORETURN; > + } > + > + gen_gvec_4_ool(get_field(s->fields, v1), get_field(s->fields, v2), > + get_field(s->fields, v3), get_field(s->fields, v4), 0, > + gen_helper_gvec_vaccc128); > + return DISAS_NEXT; > +} An inline expansion could be One possible expansion is tcg_gen_andi_i64(tl, cl, 1); tcg_gen_add2_i64(tl, th, tl, zero, al, zero); tcg_gen_add2_i64(tl, th, tl, th, bl, zero); tcg_gen_add2_i64(tl, th, th, zero, ah, zero); tcg_gen_add2_i64(tl, th, tl, th, bl, zero); /* carry out in th */ This is 8 insns for the addition vs the hw optimal 6, but we're not exactly an optimizing compiler either. ;-) r~
On 12.04.19 23:58, Richard Henderson wrote: > On 4/11/19 12:08 AM, David Hildenbrand wrote: >> +static DisasJumpType op_vaccc(DisasContext *s, DisasOps *o) >> +{ >> + if (get_field(s->fields, m5) != ES_128) { >> + gen_program_exception(s, PGM_SPECIFICATION); >> + return DISAS_NORETURN; >> + } >> + >> + gen_gvec_4_ool(get_field(s->fields, v1), get_field(s->fields, v2), >> + get_field(s->fields, v3), get_field(s->fields, v4), 0, >> + gen_helper_gvec_vaccc128); >> + return DISAS_NEXT; >> +} > > An inline expansion could be > > One possible expansion is > > tcg_gen_andi_i64(tl, cl, 1); > tcg_gen_add2_i64(tl, th, tl, zero, al, zero); > tcg_gen_add2_i64(tl, th, tl, th, bl, zero); > tcg_gen_add2_i64(tl, th, th, zero, ah, zero); > tcg_gen_add2_i64(tl, th, tl, th, bl, zero); > /* carry out in th */ > > This is 8 insns for the addition vs the hw optimal 6, but we're not exactly an > optimizing compiler either. ;-) > Yes, very nice! Thanks! > > r~ >
diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 2c1b223248..e1847e8877 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -147,6 +147,7 @@ DEF_HELPER_FLAGS_4(vstl, TCG_CALL_NO_WG, void, env, cptr, i64, i64) /* === Vector Integer Instructions === */ DEF_HELPER_FLAGS_4(gvec_vacc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vaccc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) #ifndef CONFIG_USER_ONLY DEF_HELPER_3(servc, i32, env, i64, i64) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 38d1e22a6d..a531b21908 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -1062,6 +1062,8 @@ F(0xe7f1, VACC, VRR_c, V, 0, 0, 0, 0, vacc, 0, IF_VEC) /* VECTOR ADD WITH CARRY */ F(0xe7bb, VAC, VRR_d, V, 0, 0, 0, 0, vac, 0, IF_VEC) +/* VECTOR ADD WITH CARRY COMPUTE CARRY */ + F(0xe7b9, VACCC, VRR_d, V, 0, 0, 0, 0, vaccc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */ diff --git a/target/s390x/translate_vx.inc.c b/target/s390x/translate_vx.inc.c index 111b0b7c69..a264aa0c5a 100644 --- a/target/s390x/translate_vx.inc.c +++ b/target/s390x/translate_vx.inc.c @@ -1122,3 +1122,16 @@ static DisasJumpType op_vac(DisasContext *s, DisasOps *o) get_field(s->fields, v4)); return DISAS_NEXT; } + +static DisasJumpType op_vaccc(DisasContext *s, DisasOps *o) +{ + if (get_field(s->fields, m5) != ES_128) { + gen_program_exception(s, PGM_SPECIFICATION); + return DISAS_NORETURN; + } + + gen_gvec_4_ool(get_field(s->fields, v1), get_field(s->fields, v2), + get_field(s->fields, v3), get_field(s->fields, v4), 0, + gen_helper_gvec_vaccc128); + return DISAS_NEXT; +} diff --git a/target/s390x/vec_int_helper.c b/target/s390x/vec_int_helper.c index 0b232571bc..97fc559da0 100644 --- a/target/s390x/vec_int_helper.c +++ b/target/s390x/vec_int_helper.c @@ -45,3 +45,19 @@ void HELPER(gvec_vacc128)(void *v1, const void *v2, const void *v3, dst->doubleword[0] = 0; dst->doubleword[1] = s390_vec_add(&tmp, v2, v3); } + +void HELPER(gvec_vaccc128)(void *v1, const void *v2, const void *v3, + const void *v4, uint32_t desc) +{ + const S390Vector old_carry = { + .doubleword[0] = 0, + .doubleword[1] = ((S390Vector *)v4)->doubleword[1] & 1, + }; + S390Vector tmp, *dst = v1; + bool carry; + + carry = s390_vec_add(&tmp, v2, v3); + carry |= s390_vec_add(&tmp, &tmp, &old_carry); + dst->doubleword[0] = 0; + dst->doubleword[1] = carry; +}
Again, use a helper as calculating the carry is even more involved than for VECTOR ADD COMPUTE CARRY. Signed-off-by: David Hildenbrand <david@redhat.com> --- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 13 +++++++++++++ target/s390x/vec_int_helper.c | 16 ++++++++++++++++ 4 files changed, 32 insertions(+)