From: "Emilio G. Cota" <cota@braap.org>
To: Richard Henderson <rth@twiddle.net>
Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH] target/arm: fix TCG temp leak in aarch64 rev16
Date: Fri, 21 Jul 2017 01:42:10 -0400 [thread overview]
Message-ID: <20170721054210.GA16334@flamenco> (raw)
In-Reply-To: <20170719233455.8740-7-rth@twiddle.net>
On Wed, Jul 19, 2017 at 13:34:47 -1000, Richard Henderson wrote:
> It is much shorter to reverse all 4 half-words in parallel
> than extract, reverse, and deposit each in turn.
>
> Suggested-by: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
> target/arm/translate-a64.c | 24 ++++++------------------
> 1 file changed, 6 insertions(+), 18 deletions(-)
>
> diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
> index 3fa39023ca..5bb0f8ef22 100644
> --- a/target/arm/translate-a64.c
> +++ b/target/arm/translate-a64.c
> @@ -4043,25 +4043,13 @@ static void handle_rev16(DisasContext *s, unsigned int sf,
> TCGv_i64 tcg_rd = cpu_reg(s, rd);
> TCGv_i64 tcg_tmp = tcg_temp_new_i64();
> TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf);
> + TCGv_i64 mask = tcg_const_i64(sf ? 0x00ff00ff00ff00ffull : 0x00ff00ff);
>
> - tcg_gen_andi_i64(tcg_tmp, tcg_rn, 0xffff);
> - tcg_gen_bswap16_i64(tcg_rd, tcg_tmp);
> -
> - tcg_gen_shri_i64(tcg_tmp, tcg_rn, 16);
> - tcg_gen_andi_i64(tcg_tmp, tcg_tmp, 0xffff);
> - tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp);
> - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, 16, 16);
> -
> - if (sf) {
> - tcg_gen_shri_i64(tcg_tmp, tcg_rn, 32);
> - tcg_gen_andi_i64(tcg_tmp, tcg_tmp, 0xffff);
> - tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp);
> - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, 32, 16);
> -
> - tcg_gen_shri_i64(tcg_tmp, tcg_rn, 48);
> - tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp);
> - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, 48, 16);
> - }
> + tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8);
> + tcg_gen_and_i64(tcg_rd, tcg_rn, mask);
> + tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask);
> + tcg_gen_shli_i64(tcg_rd, tcg_rd, 8);
> + tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp);
>
> tcg_temp_free_i64(tcg_tmp);
const leak! patch below -- cut with `git am --scissors'.
Emilio
---8<---
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
target/arm/translate-a64.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index 883e9df..58ed4c6 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -4044,20 +4044,21 @@ static void handle_rev16(DisasContext *s, unsigned int sf,
TCGv_i64 tcg_tmp = tcg_temp_new_i64();
TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf);
TCGv_i64 mask = tcg_const_i64(sf ? 0x00ff00ff00ff00ffull : 0x00ff00ff);
tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8);
tcg_gen_and_i64(tcg_rd, tcg_rn, mask);
tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask);
tcg_gen_shli_i64(tcg_rd, tcg_rd, 8);
tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp);
+ tcg_temp_free_i64(mask);
tcg_temp_free_i64(tcg_tmp);
}
/* C3.5.7 Data-processing (1 source)
* 31 30 29 28 21 20 16 15 10 9 5 4 0
* +----+---+---+-----------------+---------+--------+------+------+
* | sf | 1 | S | 1 1 0 1 0 1 1 0 | opcode2 | opcode | Rn | Rd |
* +----+---+---+-----------------+---------+--------+------+------+
*/
static void disas_data_proc_1src(DisasContext *s, uint32_t insn)
--
2.7.4
next prev parent reply other threads:[~2017-07-21 5:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-19 23:34 [Qemu-devel] [PULL v2 00/14] tcg-next patch queue Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 01/14] tcg/mips: reserve a register for the guest_base Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 02/14] util/cacheinfo: Add missing include for ppc linux Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 03/14] tcg: Expand glue macros before stringifying helper names Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 04/14] coccinelle: ignore ASTs pre-parsed cached C files Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 05/14] coccinelle: add a script to optimize tcg op using tcg_gen_extract() Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 06/14] target/arm: Optimize aarch64 rev16 Richard Henderson
2017-07-21 5:42 ` Emilio G. Cota [this message]
2017-07-21 13:16 ` [Qemu-devel] [PATCH] target/arm: fix TCG temp leak in " Peter Maydell
2017-07-21 19:16 ` Emilio G. Cota
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 07/14] target/arm: optimize aarch32 rev16 Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 08/14] target/m68k: optimize bcd_flags() using extract op Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 09/14] target/ppc: optimize various functions " Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 10/14] target/sparc: " Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 11/14] target/sparc: optimize gen_op_mulscc() using deposit op Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 12/14] target/alpha: optimize gen_cvtlq() " Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 13/14] tcg/tci: enable bswap16_i64 Richard Henderson
2017-07-19 23:34 ` [Qemu-devel] [PULL v2 14/14] tcg: Pass generic CPUState to gen_intermediate_code() Richard Henderson
2017-07-20 11:03 ` [Qemu-devel] [PULL v2 00/14] tcg-next patch queue Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170721054210.GA16334@flamenco \
--to=cota@braap.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).