From: Laurent Desnogues <laurent.desnogues@gmail.com>
To: Juha.Riihimaki@nokia.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 07/12] target-arm: fix neon vsri, vshl and vsli ops
Date: Wed, 21 Oct 2009 12:46:38 +0200 [thread overview]
Message-ID: <761ea48b0910210346t3b868d32x529b0893b79f9710@mail.gmail.com> (raw)
In-Reply-To: <FE83A2F3-69F5-4647-A3FE-CD18F4892693@nokia.com>
On Wed, Oct 21, 2009 at 12:17 PM, <Juha.Riihimaki@nokia.com> wrote:
> Shift immediate value is incorrectly overwritten by a temporary
> variable in the processing of NEON vsri, vshl and vsli instructions.
>
> Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
> ---
> diff --git a/target-arm/translate.c b/target-arm/translate.c
> index 59bf7bc..c92ecc6 100644
> --- a/target-arm/translate.c
> +++ b/target-arm/translate.c
> @@ -4094,7 +4094,7 @@ static int disas_neon_data_insn(CPUState * env,
> DisasContext *s, uint32_t insn)
> int pairwise;
> int u;
> int n;
> - uint32_t imm;
> + uint32_t imm, imm2;
I would prefer mask to imm2, but that's personal taste :-)
> TCGv tmp;
> TCGv tmp2;
> TCGv tmp3;
> @@ -4624,31 +4624,31 @@ static int disas_neon_data_insn(CPUState *
> env, DisasContext *s, uint32_t insn)
> switch (size) {
> case 0:
> if (op == 4)
> - imm = 0xff >> -shift;
> + imm2 = 0xff >> -shift;
> else
> - imm = (uint8_t)(0xff << shift);
> - imm |= imm << 8;
> - imm |= imm << 16;
> + imm2 = (uint8_t)(0xff << shift);
> + imm2 |= imm2 << 8;
> + imm2 |= imm2 << 16;
> break;
> case 1:
> if (op == 4)
> - imm = 0xffff >> -shift;
> + imm2 = 0xffff >> -shift;
> else
> - imm = (uint16_t)(0xffff << shift);
> - imm |= imm << 16;
> + imm2 = (uint16_t)(0xffff << shift);
> + imm2 |= imm2 << 16;
> break;
> case 2:
> if (op == 4)
> - imm = 0xffffffffu >> -shift;
> + imm2 = 0xffffffffu >> -shift;
> else
> - imm = 0xffffffffu << shift;
> + imm2 = 0xffffffffu << shift;
> break;
> default:
> abort();
> }
> tmp2 = neon_load_reg(rd, pass);
> - tcg_gen_andi_i32(tmp, tmp, imm);
> - tcg_gen_andi_i32(tmp2, tmp2, ~imm);
> + tcg_gen_andi_i32(tmp, tmp, imm2);
> + tcg_gen_andi_i32(tmp2, tmp2, ~imm2);
> tcg_gen_or_i32(tmp, tmp, tmp2);
> dead_tmp(tmp2);
> }
I mostly agree with this, except there's a mistake already
present in the original code: for a size of 2 the shift amount
can be 32 (look at VSRI in the ARM Architecture Reference
Manual). Note in this case, shift will be -32.
Laurent
next prev parent reply other threads:[~2009-10-21 10:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-21 10:17 [Qemu-devel] [PATCH 07/12] target-arm: fix neon vsri, vshl and vsli ops Juha.Riihimaki
2009-10-21 10:46 ` Laurent Desnogues [this message]
2009-10-22 6:49 ` Juha.Riihimaki
2009-10-22 7:18 ` Laurent Desnogues
2009-10-22 7:33 ` Juha.Riihimaki
2009-10-22 7:40 ` Laurent Desnogues
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=761ea48b0910210346t3b868d32x529b0893b79f9710@mail.gmail.com \
--to=laurent.desnogues@gmail.com \
--cc=Juha.Riihimaki@nokia.com \
--cc=qemu-devel@nongnu.org \
/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).