Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0sHw-000091-E2 for qemu-devel@nongnu.org; Thu, 22 Oct 2009 03:40:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0sHr-00006W-Rw for qemu-devel@nongnu.org; Thu, 22 Oct 2009 03:40:48 -0400 Received: from [199.232.76.173] (port=52969 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0sHr-00006P-LR for qemu-devel@nongnu.org; Thu, 22 Oct 2009 03:40:43 -0400 Received: from mail-fx0-f211.google.com ([209.85.220.211]:53576) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0sHq-0008IS-Qu for qemu-devel@nongnu.org; Thu, 22 Oct 2009 03:40:43 -0400 Received: by fxm7 with SMTP id 7so8326271fxm.34 for ; Thu, 22 Oct 2009 00:40:41 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <3987ABA9-47A8-42D3-A620-21BF89398849@nokia.com> References: <761ea48b0910210346t3b868d32x529b0893b79f9710@mail.gmail.com> <761ea48b0910220018u7a57ca09w5069d1cd1bc71740@mail.gmail.com> <3987ABA9-47A8-42D3-A620-21BF89398849@nokia.com> Date: Thu, 22 Oct 2009 09:40:41 +0200 Message-ID: <761ea48b0910220040w7350a964ia3df3a6a1b563ee@mail.gmail.com> Subject: Re: [Qemu-devel] [PATCH 07/12] target-arm: fix neon vsri, vshl and vsli ops From: Laurent Desnogues Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juha.Riihimaki@nokia.com Cc: qemu-devel@nongnu.org On Thu, Oct 22, 2009 at 9:33 AM, wrote: > > On Oct 22, 2009, at 10:18, ext Laurent Desnogues wrote: > >> On Thu, Oct 22, 2009 at 8:49 AM, =A0 wrote: >>> >>> On Oct 21, 2009, at 13:46, ext Laurent Desnogues wrote: >>> >>>>> @@ -4624,31 +4624,31 @@ static int disas_neon_data_insn(CPUState * >>>>> env, DisasContext *s, uint32_t insn) >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0switch (si= ze) { >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0case 0: >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if= (op =3D=3D 4) >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm =3D 0xff >> -shift; >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm2 =3D 0xff >> -shift; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0el= se >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm =3D (uint8_t)(0xff << >>>>> shift); >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imm = |=3D imm << 8; >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imm = |=3D imm << 16; >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm2 =3D (uint8_t)(0xff << >>>>> shift); >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imm2= |=3D imm2 << 8; >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imm2= |=3D imm2 << 16; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0br= eak; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0case 1: >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if= (op =3D=3D 4) >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm =3D 0xffff >> -shift; >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm2 =3D 0xffff >> -shift; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0el= se >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm =3D (uint16_t)(0xffff << >>>>> shift); >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imm = |=3D imm << 16; >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm2 =3D (uint16_t)(0xffff << >>>>> shift); >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imm2= |=3D imm2 << 16; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0br= eak; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0case 2: >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if= (op =3D=3D 4) >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm =3D 0xffffffffu >> -shift; >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm2 =3D 0xffffffffu >> -shift; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0el= se >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm =3D 0xffffffffu << shift; >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0imm2 =3D 0xffffffffu << shift; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0br= eak; >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0default: >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ab= ort(); >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmp2 =3D n= eon_load_reg(rd, pass); >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tcg_gen_andi= _i32(tmp, tmp, imm); >>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tcg_gen_andi= _i32(tmp2, tmp2, ~imm); >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tcg_gen_andi= _i32(tmp, tmp, imm2); >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tcg_gen_andi= _i32(tmp2, tmp2, ~imm2); >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tcg_gen_or= _i32(tmp, tmp, tmp2); >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dead_tmp(t= mp2); >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >>>> >>>> I mostly agree with this, except there's a mistake already >>>> present in the original code: =A0for a size of 2 the shift amount >>>> can be 32 (look at VSRI in the ARM Architecture Reference >>>> Manual). =A0Note in this case, shift will be -32. >>> >>> True. However, I'm not sure if this causes incorrect behavior or not. >>> I'm not a NEON expert but how I understand the VSRI instruction is >>> that it will shift the element value before it is inserted in the >>> destination vector, therefore with element size 2 and shift 32 the >>> result would be always zero and I guess that would still apply if the >>> shift was -32: does it matter in which direction you shift if you >>> anyway shift all the bits out? >> >> The problem is not in the NEON semantics but rather the C >> one: =A0the behaviour of a shift by an amount greater than or >> equal to the bit-width of the type is undefined; =A0in this case >> imm2 is 32-bit and the shift is 32-bit. =A0What you want is >> imm2 =3D 0 if shift is -32, as you correctly guessed. > > Ah, I see. Doesn't the same issue apply for the 8bit and 16bit element > sizes as well? I suppose it will be sufficient to check for a negative > shift value and in that case force the mask value to zero. For 8- and 16-bit elements, your shift will always be <=3D 16 (in absolute value I mean :-), so you have no issue for these cases. Laurent