[PATCH 1/2] target/ppc: Use tcg_constant_i32() in gen_setb()

Philippe Mathieu-Daudé posted 2 patches 4 years, 4 months ago
[PATCH 1/2] target/ppc: Use tcg_constant_i32() in gen_setb()
Posted by Philippe Mathieu-Daudé 4 years, 4 months ago
Avoid using TCG temporaries for the -1 and 8 constant values.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/translate.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index b985e9e55bc..193d8e89152 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -5074,19 +5074,15 @@ static void gen_mtspr(DisasContext *ctx)
 static void gen_setb(DisasContext *ctx)
 {
     TCGv_i32 t0 = tcg_temp_new_i32();
-    TCGv_i32 t8 = tcg_temp_new_i32();
-    TCGv_i32 tm1 = tcg_temp_new_i32();
+    TCGv_i32 t8 = tcg_constant_i32(8);
+    TCGv_i32 tm1 = tcg_constant_i32(-1);
     int crf = crfS(ctx->opcode);
 
     tcg_gen_setcondi_i32(TCG_COND_GEU, t0, cpu_crf[crf], 4);
-    tcg_gen_movi_i32(t8, 8);
-    tcg_gen_movi_i32(tm1, -1);
     tcg_gen_movcond_i32(TCG_COND_GEU, t0, cpu_crf[crf], t8, tm1, t0);
     tcg_gen_ext_i32_tl(cpu_gpr[rD(ctx->opcode)], t0);
 
     tcg_temp_free_i32(t0);
-    tcg_temp_free_i32(t8);
-    tcg_temp_free_i32(tm1);
 }
 #endif
 
-- 
2.31.1

Re: [PATCH 1/2] target/ppc: Use tcg_constant_i32() in gen_setb()
Posted by Richard Henderson 4 years, 4 months ago
On 10/3/21 10:17 AM, Philippe Mathieu-Daudé wrote:
> Avoid using TCG temporaries for the -1 and 8 constant values.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/ppc/translate.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

Re: [PATCH 1/2] target/ppc: Use tcg_constant_i32() in gen_setb()
Posted by David Gibson 4 years, 4 months ago
On Sun, Oct 03, 2021 at 04:17:10PM +0200, Philippe Mathieu-Daudé wrote:
> Avoid using TCG temporaries for the -1 and 8 constant values.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Both patches applied to ppc-for-6.2, thanks.

> ---
>  target/ppc/translate.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index b985e9e55bc..193d8e89152 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -5074,19 +5074,15 @@ static void gen_mtspr(DisasContext *ctx)
>  static void gen_setb(DisasContext *ctx)
>  {
>      TCGv_i32 t0 = tcg_temp_new_i32();
> -    TCGv_i32 t8 = tcg_temp_new_i32();
> -    TCGv_i32 tm1 = tcg_temp_new_i32();
> +    TCGv_i32 t8 = tcg_constant_i32(8);
> +    TCGv_i32 tm1 = tcg_constant_i32(-1);
>      int crf = crfS(ctx->opcode);
>  
>      tcg_gen_setcondi_i32(TCG_COND_GEU, t0, cpu_crf[crf], 4);
> -    tcg_gen_movi_i32(t8, 8);
> -    tcg_gen_movi_i32(tm1, -1);
>      tcg_gen_movcond_i32(TCG_COND_GEU, t0, cpu_crf[crf], t8, tm1, t0);
>      tcg_gen_ext_i32_tl(cpu_gpr[rD(ctx->opcode)], t0);
>  
>      tcg_temp_free_i32(t0);
> -    tcg_temp_free_i32(t8);
> -    tcg_temp_free_i32(tm1);
>  }
>  #endif
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson