From 456fb66617a6c0f0b846463148e2a6e82068d2df Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 1 Mar 2021 19:45:29 -0500 Subject: [PATCH] tcg: Fix generation of dupi_vec for 32-bit host The definition of INDEX_op_dupi_vec is that it operates on units of tcg_target_ulong -- in this case 32 bits. It does not work to use this for a uint64_t value that happens to be small enough to fit in tcg_target_ulong. Backports a5b30d950c42b14bc9da24d1e68add6538d23336 --- qemu/tcg/tcg-op-vec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qemu/tcg/tcg-op-vec.c b/qemu/tcg/tcg-op-vec.c index 6cd71dd6..b246c579 100644 --- a/qemu/tcg/tcg-op-vec.c +++ b/qemu/tcg/tcg-op-vec.c @@ -254,10 +254,10 @@ TCGv_vec tcg_const_ones_vec_matching(TCGContext *s, TCGv_vec m) void tcg_gen_dup64i_vec(TCGContext *s, TCGv_vec r, uint64_t a) { - if (TCG_TARGET_REG_BITS == 32 && a == deposit64(a, 32, 32, a)) { - do_dupi_vec(s, r, MO_32, a); - } else if (TCG_TARGET_REG_BITS == 64 || a == (uint64_t)(int32_t)a) { + if (TCG_TARGET_REG_BITS == 64) { do_dupi_vec(s, r, MO_64, a); + } else if (a == dup_const(MO_32, a)) { + do_dupi_vec(s, r, MO_32, a); } else { TCGv_i64 c = tcg_const_i64(s, a); tcg_gen_dup_i64_vec(s, MO_64, r, c); @@ -282,7 +282,11 @@ void tcg_gen_dup8i_vec(TCGContext *s, TCGv_vec r, uint32_t a) void tcg_gen_dupi_vec(TCGContext *s, unsigned vece, TCGv_vec r, uint64_t a) { - do_dupi_vec(s, r, MO_REG, dup_const(vece, a)); + if (vece == MO_64) { + tcg_gen_dup64i_vec(s, r, a); + } else { + do_dupi_vec(s, r, MO_REG, dup_const(vece, a)); + } } void tcg_gen_dup_i64_vec(TCGContext *s, unsigned vece, TCGv_vec r, TCGv_i64 a)