[v3,31/38] target-microblaze: Simplify address computation using tcg_gen_addi_i32()

Message ID 20180516185146.30708-32-edgar.iglesias@gmail.com
State New
Headers show
Series
  • target-microblaze: Add support for Extended Addressing
Related show

Commit Message

Edgar E. Iglesias May 16, 2018, 6:51 p.m.
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Simplify address computation using tcg_gen_addi_i32().
tcg_gen_addi_i32() already optimizes the case when the
immediate is zero.

No functional change.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 target/microblaze/translate.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Philippe Mathieu-Daudé May 17, 2018, 6:19 p.m. | #1
On 05/16/2018 03:51 PM, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> 
> Simplify address computation using tcg_gen_addi_i32().
> tcg_gen_addi_i32() already optimizes the case when the
> immediate is zero.
> 
> No functional change.
> 
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  target/microblaze/translate.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
> index 39c4d0654e..44395cf189 100644
> --- a/target/microblaze/translate.c
> +++ b/target/microblaze/translate.c
> @@ -899,12 +899,7 @@ static inline void compute_ldst_addr(DisasContext *dc, bool ea, TCGv t)
>      /* Immediate.  */
>      t32 = tcg_temp_new_i32();
>      if (!extimm) {
> -        if (dc->imm == 0) {
> -            tcg_gen_mov_i32(t32, cpu_R[dc->ra]);
> -        } else {
> -            tcg_gen_movi_i32(t32, (int32_t)((int16_t)dc->imm));
> -            tcg_gen_add_i32(t32, cpu_R[dc->ra], t32);
> -        }
> +        tcg_gen_addi_i32(t32, cpu_R[dc->ra], (int16_t)dc->imm);
>      } else {
>          tcg_gen_add_i32(t32, cpu_R[dc->ra], *(dec_alu_op_b(dc)));
>      }
>

Patch

diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
index 39c4d0654e..44395cf189 100644
--- a/target/microblaze/translate.c
+++ b/target/microblaze/translate.c
@@ -899,12 +899,7 @@  static inline void compute_ldst_addr(DisasContext *dc, bool ea, TCGv t)
     /* Immediate.  */
     t32 = tcg_temp_new_i32();
     if (!extimm) {
-        if (dc->imm == 0) {
-            tcg_gen_mov_i32(t32, cpu_R[dc->ra]);
-        } else {
-            tcg_gen_movi_i32(t32, (int32_t)((int16_t)dc->imm));
-            tcg_gen_add_i32(t32, cpu_R[dc->ra], t32);
-        }
+        tcg_gen_addi_i32(t32, cpu_R[dc->ra], (int16_t)dc->imm);
     } else {
         tcg_gen_add_i32(t32, cpu_R[dc->ra], *(dec_alu_op_b(dc)));
     }