tcg: Expand vector minmax using cmp+cmpsel

Provide a generic fallback for the min/max operations.

Backports commit 72b4c792c7a576d9246207a8e9a940ed9e191722 from qemu
This commit is contained in:
Richard Henderson 2019-05-24 18:26:51 -04:00 committed by Lioncash
parent 56d35e80aa
commit 568da655c6
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -121,6 +121,10 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list,
}
break;
case INDEX_op_cmpsel_vec:
case INDEX_op_smin_vec:
case INDEX_op_smax_vec:
case INDEX_op_umin_vec:
case INDEX_op_umax_vec:
if (tcg_can_emit_vec_op(INDEX_op_cmp_vec, type, vece)) {
continue;
}
@ -633,24 +637,32 @@ void tcg_gen_ussub_vec(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_vec a, TCG
do_op3_nofail(s, vece, r, a, b, INDEX_op_ussub_vec);
}
static void do_minmax(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_vec a,
TCGv_vec b, TCGOpcode opc, TCGCond cond)
{
if (!do_op3(s, vece, r, a, b, opc)) {
tcg_gen_cmpsel_vec(s, cond, vece, r, a, b, a, b);
}
}
void tcg_gen_smin_vec(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
do_op3_nofail(s, vece, r, a, b, INDEX_op_smin_vec);
do_minmax(s, vece, r, a, b, INDEX_op_smin_vec, TCG_COND_LT);
}
void tcg_gen_umin_vec(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
do_op3_nofail(s, vece, r, a, b, INDEX_op_umin_vec);
do_minmax(s, vece, r, a, b, INDEX_op_umin_vec, TCG_COND_LTU);
}
void tcg_gen_smax_vec(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
do_op3_nofail(s, vece, r, a, b, INDEX_op_smax_vec);
do_minmax(s, vece, r, a, b, INDEX_op_smax_vec, TCG_COND_GT);
}
void tcg_gen_umax_vec(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
do_op3_nofail(s, vece, r, a, b, INDEX_op_umax_vec);
do_minmax(s, vece, r, a, b, INDEX_op_umax_vec, TCG_COND_GTU);
}
void tcg_gen_shlv_vec(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)