diff mbox series

target/arm: Fix sign-extension for SMLAL*

Message ID 20190912183058.17947-1-richard.henderson@linaro.org
State Accepted
Commit 1ab170865202aab8301131f31bffd87ea0f60d16
Headers show
Series target/arm: Fix sign-extension for SMLAL* | expand

Commit Message

Richard Henderson Sept. 12, 2019, 6:30 p.m. UTC
The 32-bit product should be sign-extended, not zero-extended.

Fixes: ea96b374641b
Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 target/arm/translate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Laurent Desnogues Sept. 13, 2019, 6:03 a.m. UTC | #1
Hello,

On Thu, Sep 12, 2019 at 8:31 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>

> The 32-bit product should be sign-extended, not zero-extended.

>

> Fixes: ea96b374641b

> Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


No more failures on my tests.

Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com>


Thanks,

Laurent

> ---

>  target/arm/translate.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

>

> diff --git a/target/arm/translate.c b/target/arm/translate.c

> index 34bb280e3d..fd2f0e3048 100644

> --- a/target/arm/translate.c

> +++ b/target/arm/translate.c

> @@ -8045,7 +8045,9 @@ static bool op_smlaxxx(DisasContext *s, arg_rrrr *a,

>      case 2:

>          tl = load_reg(s, a->ra);

>          th = load_reg(s, a->rd);

> -        t1 = tcg_const_i32(0);

> +        /* Sign-extend the 32-bit product to 64 bits.  */

> +        t1 = tcg_temp_new_i32();

> +        tcg_gen_sari_i32(t1, t0, 31);

>          tcg_gen_add2_i32(tl, th, tl, th, t0, t1);

>          tcg_temp_free_i32(t0);

>          tcg_temp_free_i32(t1);

> --

> 2.17.1

>
Philippe Mathieu-Daudé Sept. 13, 2019, 11:01 a.m. UTC | #2
On 9/12/19 8:30 PM, Richard Henderson wrote:
> The 32-bit product should be sign-extended, not zero-extended.

> 

> Fixes: ea96b374641b

> Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


> ---

>  target/arm/translate.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/target/arm/translate.c b/target/arm/translate.c

> index 34bb280e3d..fd2f0e3048 100644

> --- a/target/arm/translate.c

> +++ b/target/arm/translate.c

> @@ -8045,7 +8045,9 @@ static bool op_smlaxxx(DisasContext *s, arg_rrrr *a,

>      case 2:

>          tl = load_reg(s, a->ra);

>          th = load_reg(s, a->rd);

> -        t1 = tcg_const_i32(0);

> +        /* Sign-extend the 32-bit product to 64 bits.  */

> +        t1 = tcg_temp_new_i32();

> +        tcg_gen_sari_i32(t1, t0, 31);

>          tcg_gen_add2_i32(tl, th, tl, th, t0, t1);

>          tcg_temp_free_i32(t0);

>          tcg_temp_free_i32(t1);

>
Richard Henderson Oct. 14, 2019, 11:42 p.m. UTC | #3
Ping.

On 9/12/19 11:30 AM, Richard Henderson wrote:
> The 32-bit product should be sign-extended, not zero-extended.

> 

> Fixes: ea96b374641b

> Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  target/arm/translate.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/target/arm/translate.c b/target/arm/translate.c

> index 34bb280e3d..fd2f0e3048 100644

> --- a/target/arm/translate.c

> +++ b/target/arm/translate.c

> @@ -8045,7 +8045,9 @@ static bool op_smlaxxx(DisasContext *s, arg_rrrr *a,

>      case 2:

>          tl = load_reg(s, a->ra);

>          th = load_reg(s, a->rd);

> -        t1 = tcg_const_i32(0);

> +        /* Sign-extend the 32-bit product to 64 bits.  */

> +        t1 = tcg_temp_new_i32();

> +        tcg_gen_sari_i32(t1, t0, 31);

>          tcg_gen_add2_i32(tl, th, tl, th, t0, t1);

>          tcg_temp_free_i32(t0);

>          tcg_temp_free_i32(t1);

>
Peter Maydell Oct. 17, 2019, 1:52 p.m. UTC | #4
On Tue, 15 Oct 2019 at 00:42, Richard Henderson
<richard.henderson@linaro.org> wrote:
>

> Ping.

>

> On 9/12/19 11:30 AM, Richard Henderson wrote:

> > The 32-bit product should be sign-extended, not zero-extended.

> >

> > Fixes: ea96b374641b

> > Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>

> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org>




Applied to target-arm.next, thanks.

-- PMM
diff mbox series

Patch

diff --git a/target/arm/translate.c b/target/arm/translate.c
index 34bb280e3d..fd2f0e3048 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -8045,7 +8045,9 @@  static bool op_smlaxxx(DisasContext *s, arg_rrrr *a,
     case 2:
         tl = load_reg(s, a->ra);
         th = load_reg(s, a->rd);
-        t1 = tcg_const_i32(0);
+        /* Sign-extend the 32-bit product to 64 bits.  */
+        t1 = tcg_temp_new_i32();
+        tcg_gen_sari_i32(t1, t0, 31);
         tcg_gen_add2_i32(tl, th, tl, th, t0, t1);
         tcg_temp_free_i32(t0);
         tcg_temp_free_i32(t1);