Use the same mask to avoid having to load two different constants, as
suggest by Richard Henderson. Also use one less temp.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target/cris/translate.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/target/cris/translate.c b/target/cris/translate.c
index 0ee05ca02d..103b214233 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -433,20 +433,19 @@ static inline void t_gen_subx_carry(DisasContext *dc, TCGv d)
T0 = ((T0 << 8) & 0xff00ff00) | ((T0 >> 8) & 0x00ff00ff) */
static inline void t_gen_swapb(TCGv d, TCGv s)
{
- TCGv t, org_s;
+ TCGv t, m;
t = tcg_temp_new();
- org_s = tcg_temp_new();
+ m = tcg_const_tl(0x00ff00ff);
/* d and s may refer to the same object. */
- 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_shri_tl(t, s, 8);
+ tcg_gen_and_tl(t, t, m);
+ tcg_gen_and_tl(d, s, m);
+ tcg_gen_shli_tl(d, d, 8);
tcg_gen_or_tl(d, d, t);
+ tcg_temp_free(m);
tcg_temp_free(t);
- tcg_temp_free(org_s);
}
/* Swap the halfwords of the s operand. */
--
2.11.0
On 05/16/2017 08:01 PM, Aurelien Jarno wrote:
> Use the same mask to avoid having to load two different constants, as
> suggest by Richard Henderson. Also use one less temp.
>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> target/cris/translate.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/target/cris/translate.c b/target/cris/translate.c
> index 0ee05ca02d..103b214233 100644
> --- a/target/cris/translate.c
> +++ b/target/cris/translate.c
> @@ -433,20 +433,19 @@ static inline void t_gen_subx_carry(DisasContext *dc, TCGv d)
> T0 = ((T0 << 8) & 0xff00ff00) | ((T0 >> 8) & 0x00ff00ff) */
> static inline void t_gen_swapb(TCGv d, TCGv s)
> {
> - TCGv t, org_s;
> + TCGv t, m;
>
> t = tcg_temp_new();
> - org_s = tcg_temp_new();
> + m = tcg_const_tl(0x00ff00ff);
>
> /* d and s may refer to the same object. */
> - 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_shri_tl(t, s, 8);
> + tcg_gen_and_tl(t, t, m);
> + tcg_gen_and_tl(d, s, m);
Eventually add a comment /* set d 0xff00ff00 */
Anyway,
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> + tcg_gen_shli_tl(d, d, 8);
> tcg_gen_or_tl(d, d, t);
> + tcg_temp_free(m);
> tcg_temp_free(t);
> - tcg_temp_free(org_s);
> }
>
> /* Swap the halfwords of the s operand. */
>
On 05/16/2017 04:01 PM, Aurelien Jarno wrote: > Use the same mask to avoid having to load two different constants, as > suggest by Richard Henderson. Also use one less temp. > > Signed-off-by: Aurelien Jarno<aurelien@aurel32.net> > --- > target/cris/translate.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) Reviewed-by: Richard Henderson <rth@twiddle.net> r~
© 2016 - 2026 Red Hat, Inc.