diff mbox series

[09/18] tcg/loongarch64: Use tcg_out_dup_vec in tcg_out_dupi_vec

Message ID 20240527211912.14060-10-richard.henderson@linaro.org
State Superseded
Headers show
Series tcg/loongarch64: Support v64 and v256 | expand

Commit Message

Richard Henderson May 27, 2024, 9:19 p.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/loongarch64/tcg-target.c.inc | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

Comments

Philippe Mathieu-Daudé May 29, 2024, 6:36 a.m. UTC | #1
On 27/5/24 23:19, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/loongarch64/tcg-target.c.inc | 18 +-----------------
>   1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
> index 1e721b8b20..9a8f67cf3e 100644
> --- a/tcg/loongarch64/tcg-target.c.inc
> +++ b/tcg/loongarch64/tcg-target.c.inc
> @@ -1749,24 +1749,8 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece,
>   
>       /* TODO: vldi patterns when imm 12 is set */
>   
> -    /* Fallback to vreplgr2vr */
>       tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP0, value);
> -    switch (vece) {
> -    case MO_8:
> -        tcg_out_opc_vreplgr2vr_b(s, rd, TCG_REG_TMP0);
> -        break;
> -    case MO_16:
> -        tcg_out_opc_vreplgr2vr_h(s, rd, TCG_REG_TMP0);
> -        break;
> -    case MO_32:
> -        tcg_out_opc_vreplgr2vr_w(s, rd, TCG_REG_TMP0);
> -        break;
> -    case MO_64:
> -        tcg_out_opc_vreplgr2vr_d(s, rd, TCG_REG_TMP0);
> -        break;
> -    default:
> -        g_assert_not_reached();
> -    }
> +    tcg_out_dup_vec(s, type, vece, rd, TCG_REG_TMP0);

Indeed, I noticed the same simplification :)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

>   }
Song Gao June 17, 2024, 10:06 a.m. UTC | #2
在 2024/5/28 上午5:19, Richard Henderson 写道:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/loongarch64/tcg-target.c.inc | 18 +-----------------
>   1 file changed, 1 insertion(+), 17 deletions(-)
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
> diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
> index 1e721b8b20..9a8f67cf3e 100644
> --- a/tcg/loongarch64/tcg-target.c.inc
> +++ b/tcg/loongarch64/tcg-target.c.inc
> @@ -1749,24 +1749,8 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece,
>   
>       /* TODO: vldi patterns when imm 12 is set */
>   
> -    /* Fallback to vreplgr2vr */
>       tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP0, value);
> -    switch (vece) {
> -    case MO_8:
> -        tcg_out_opc_vreplgr2vr_b(s, rd, TCG_REG_TMP0);
> -        break;
> -    case MO_16:
> -        tcg_out_opc_vreplgr2vr_h(s, rd, TCG_REG_TMP0);
> -        break;
> -    case MO_32:
> -        tcg_out_opc_vreplgr2vr_w(s, rd, TCG_REG_TMP0);
> -        break;
> -    case MO_64:
> -        tcg_out_opc_vreplgr2vr_d(s, rd, TCG_REG_TMP0);
> -        break;
> -    default:
> -        g_assert_not_reached();
> -    }
> +    tcg_out_dup_vec(s, type, vece, rd, TCG_REG_TMP0);
>   }
>   
>   static void tcg_out_addsub_vec(TCGContext *s, unsigned vece, const TCGArg a0,
diff mbox series

Patch

diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index 1e721b8b20..9a8f67cf3e 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -1749,24 +1749,8 @@  static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece,
 
     /* TODO: vldi patterns when imm 12 is set */
 
-    /* Fallback to vreplgr2vr */
     tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP0, value);
-    switch (vece) {
-    case MO_8:
-        tcg_out_opc_vreplgr2vr_b(s, rd, TCG_REG_TMP0);
-        break;
-    case MO_16:
-        tcg_out_opc_vreplgr2vr_h(s, rd, TCG_REG_TMP0);
-        break;
-    case MO_32:
-        tcg_out_opc_vreplgr2vr_w(s, rd, TCG_REG_TMP0);
-        break;
-    case MO_64:
-        tcg_out_opc_vreplgr2vr_d(s, rd, TCG_REG_TMP0);
-        break;
-    default:
-        g_assert_not_reached();
-    }
+    tcg_out_dup_vec(s, type, vece, rd, TCG_REG_TMP0);
 }
 
 static void tcg_out_addsub_vec(TCGContext *s, unsigned vece, const TCGArg a0,