diff mbox series

[3/4] target/ppc: Use tcg_constant_tl() in gen_op_cmp()

Message ID 20211024161619.325903-4-f4bug@amsat.org
State Accepted, archived
Headers show
Series target/alpha,arm,ppc: More uses of tcg_constant() | expand

Commit Message

Philippe Mathieu-Daudé Oct. 24, 2021, 4:16 p.m. UTC
Avoid using a TCG temporary by moving the compared values
to the constant pool.

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

Comments

Richard Henderson Oct. 24, 2021, 9:25 p.m. UTC | #1
On 10/24/21 9:16 AM, Philippe Mathieu-Daudé wrote:
> Avoid using a TCG temporary by moving the compared values
> to the constant pool.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/ppc/translate.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)

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

r~
David Gibson Oct. 25, 2021, 12:21 a.m. UTC | #2
On Sun, Oct 24, 2021 at 06:16:18PM +0200, Philippe Mathieu-Daudé wrote:
> Avoid using a TCG temporary by moving the compared values
> to the constant pool.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  target/ppc/translate.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index 518337bcb7f..507f6699f47 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -1430,23 +1430,20 @@ static opc_handler_t invalid_handler = {
>  static inline void gen_op_cmp(TCGv arg0, TCGv arg1, int s, int crf)
>  {
>      TCGv t0 = tcg_temp_new();
> -    TCGv t1 = tcg_temp_new();
>      TCGv_i32 t = tcg_temp_new_i32();
>  
> -    tcg_gen_movi_tl(t0, CRF_EQ);
> -    tcg_gen_movi_tl(t1, CRF_LT);
>      tcg_gen_movcond_tl((s ? TCG_COND_LT : TCG_COND_LTU),
> -                       t0, arg0, arg1, t1, t0);
> -    tcg_gen_movi_tl(t1, CRF_GT);
> +                       t0, arg0, arg1,
> +                       tcg_constant_tl(CRF_LT), tcg_constant_tl(CRF_EQ));
>      tcg_gen_movcond_tl((s ? TCG_COND_GT : TCG_COND_GTU),
> -                       t0, arg0, arg1, t1, t0);
> +                       t0, arg0, arg1,
> +                       tcg_constant_tl(CRF_GT), t0);
>  
>      tcg_gen_trunc_tl_i32(t, t0);
>      tcg_gen_trunc_tl_i32(cpu_crf[crf], cpu_so);
>      tcg_gen_or_i32(cpu_crf[crf], cpu_crf[crf], t);
>  
>      tcg_temp_free(t0);
> -    tcg_temp_free(t1);
>      tcg_temp_free_i32(t);
>  }
>
diff mbox series

Patch

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 518337bcb7f..507f6699f47 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -1430,23 +1430,20 @@  static opc_handler_t invalid_handler = {
 static inline void gen_op_cmp(TCGv arg0, TCGv arg1, int s, int crf)
 {
     TCGv t0 = tcg_temp_new();
-    TCGv t1 = tcg_temp_new();
     TCGv_i32 t = tcg_temp_new_i32();
 
-    tcg_gen_movi_tl(t0, CRF_EQ);
-    tcg_gen_movi_tl(t1, CRF_LT);
     tcg_gen_movcond_tl((s ? TCG_COND_LT : TCG_COND_LTU),
-                       t0, arg0, arg1, t1, t0);
-    tcg_gen_movi_tl(t1, CRF_GT);
+                       t0, arg0, arg1,
+                       tcg_constant_tl(CRF_LT), tcg_constant_tl(CRF_EQ));
     tcg_gen_movcond_tl((s ? TCG_COND_GT : TCG_COND_GTU),
-                       t0, arg0, arg1, t1, t0);
+                       t0, arg0, arg1,
+                       tcg_constant_tl(CRF_GT), t0);
 
     tcg_gen_trunc_tl_i32(t, t0);
     tcg_gen_trunc_tl_i32(cpu_crf[crf], cpu_so);
     tcg_gen_or_i32(cpu_crf[crf], cpu_crf[crf], t);
 
     tcg_temp_free(t0);
-    tcg_temp_free(t1);
     tcg_temp_free_i32(t);
 }