[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 36/38] tcg: Expand vector minmax using cmp+cmpsel
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 36/38] tcg: Expand vector minmax using cmp+cmpsel |
Date: |
Fri, 19 Apr 2019 21:34:40 -1000 |
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/tcg-op-gvec.c | 8 ++++++++
tcg/tcg-op-vec.c | 19 +++++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c
index e7029d26f4..dddb00719a 100644
--- a/tcg/tcg-op-gvec.c
+++ b/tcg/tcg-op-gvec.c
@@ -99,6 +99,14 @@ static bool tcg_can_emit_vecop_list(const TCGOpcode *list,
case INDEX_op_cmpsel_vec:
/* Fallback expansion uses only required logial ops. */
continue;
+ 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;
+ }
+ break;
default:
break;
}
diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
index 5868a51270..43abeb0674 100644
--- a/tcg/tcg-op-vec.c
+++ b/tcg/tcg-op-vec.c
@@ -520,24 +520,35 @@ void tcg_gen_ussub_vec(unsigned vece, TCGv_vec r,
TCGv_vec a, TCGv_vec b)
do_op3_nofail(vece, r, a, b, INDEX_op_ussub_vec);
}
+static void do_minmax(unsigned vece, TCGv_vec r, TCGv_vec a,
+ TCGv_vec b, TCGOpcode opc, TCGCond cond)
+{
+ if (!do_op3(vece, r, a, b, opc)) {
+ TCGv_vec t = tcg_temp_new_vec_matching(r);
+ tcg_gen_cmp_vec(cond, vece, t, a, b);
+ tcg_gen_cmpsel_vec(vece, r, t, a, b);
+ tcg_temp_free_vec(t);
+ }
+}
+
void tcg_gen_smin_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
- do_op3_nofail(vece, r, a, b, INDEX_op_smin_vec);
+ do_minmax(vece, r, a, b, INDEX_op_smin_vec, TCG_COND_GT);
}
void tcg_gen_umin_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
- do_op3_nofail(vece, r, a, b, INDEX_op_umin_vec);
+ do_minmax(vece, r, a, b, INDEX_op_umin_vec, TCG_COND_LTU);
}
void tcg_gen_smax_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
- do_op3_nofail(vece, r, a, b, INDEX_op_smax_vec);
+ do_minmax(vece, r, a, b, INDEX_op_smax_vec, TCG_COND_GT);
}
void tcg_gen_umax_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
{
- do_op3_nofail(vece, r, a, b, INDEX_op_umax_vec);
+ do_minmax(vece, r, a, b, INDEX_op_umax_vec, TCG_COND_GTU);
}
void tcg_gen_shlv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
--
2.17.1
- [Qemu-devel] [PATCH 37/38] tcg/aarch64: Use MVNI for expansion of dupi, (continued)
- [Qemu-devel] [PATCH 37/38] tcg/aarch64: Use MVNI for expansion of dupi, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 26/38] tcg/i386: Support vector absolute value, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 31/38] target/ppc: Use vector variable shifts for VS{L, R, RA}{B, H, W, D}, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 35/38] tcg: Introduce do_op3_nofail for vector expansion, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 33/38] tcg/aarch64: Do not advertise minmax for MO_64, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 29/38] tcg/i386: Support vector comparison select value, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 38/38] tcg/aarch64: Use ORRI and BICI for vector logical operations, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 28/38] tcg: Add support for vector comparison select, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 22/38] target/cris: Use tcg_gen_abs_tl, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 36/38] tcg: Expand vector minmax using cmp+cmpsel,
Richard Henderson <=
- [Qemu-devel] [PATCH 20/38] tcg: Add support for vector absolute value, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 27/38] tcg/aarch64: Support vector absolute value, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 30/38] tcg/aarch64: Support vector comparison select value, Richard Henderson, 2019/04/20
- [Qemu-devel] [PATCH 32/38] target/arm: Vectorize USHL and SSHL, Richard Henderson, 2019/04/20
- Re: [Qemu-devel] [PATCH 00/38] tcg vector improvements, no-reply, 2019/04/20
- Re: [Qemu-devel] [PATCH 00/38] tcg vector improvements, David Hildenbrand, 2019/04/23
- Re: [Qemu-devel] [PATCH 00/38] tcg vector improvements, David Hildenbrand, 2019/04/29