diff mbox

[4/8] target/cris: optimize gen_swapb() using extract op

Message ID 20170510200535.13268-5-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show

Commit Message

Philippe Mathieu-Daudé May 10, 2017, 8:05 p.m. UTC
Applied using Coccinelle script.

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

Comments

Philippe Mathieu-Daudé May 12, 2017, 1:29 a.m. UTC | #1
Hi,

As reviewd by Richard this patch is WRONG, so need to further review :)

http://lists.nongnu.org/archive/html/qemu-devel/2017-05/msg02551.html

On 05/10/2017 05:05 PM, Philippe Mathieu-Daudé wrote:
> Applied using Coccinelle script.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/cris/translate.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/target/cris/translate.c b/target/cris/translate.c
> index 0ee05ca02d..c03403ac62 100644
> --- a/target/cris/translate.c
> +++ b/target/cris/translate.c
> @@ -442,8 +442,7 @@ static inline void t_gen_swapb(TCGv d, TCGv s)
>      tcg_gen_mov_tl(org_s, s);
>      tcg_gen_shli_tl(t, org_s, 8);
>      tcg_gen_andi_tl(d, t, 0xff00ff00);
> -    tcg_gen_shri_tl(t, org_s, 8);
> -    tcg_gen_andi_tl(t, t, 0x00ff00ff);
> +    tcg_gen_extract_tl(t, org_s, 8, 0x00ff00ff);
>      tcg_gen_or_tl(d, d, t);
>      tcg_temp_free(t);
>      tcg_temp_free(org_s);
>

corrected Coccinelle script displays:

candidate at target/cris/translate.c:445
   op_size: tl/tl (same)
   low_bits: 8 (value: 0xff)
   len: 0xff00ff
   len_bits != low_bits
   candidate is NOT optimizable
diff mbox

Patch

diff --git a/target/cris/translate.c b/target/cris/translate.c
index 0ee05ca02d..c03403ac62 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -442,8 +442,7 @@  static inline void t_gen_swapb(TCGv d, TCGv s)
     tcg_gen_mov_tl(org_s, s);
     tcg_gen_shli_tl(t, org_s, 8);
     tcg_gen_andi_tl(d, t, 0xff00ff00);
-    tcg_gen_shri_tl(t, org_s, 8);
-    tcg_gen_andi_tl(t, t, 0x00ff00ff);
+    tcg_gen_extract_tl(t, org_s, 8, 0x00ff00ff);
     tcg_gen_or_tl(d, d, t);
     tcg_temp_free(t);
     tcg_temp_free(org_s);