Skip to contentSkip to conversation

target/arm: Fix sign-extension for SMLAL*

PATCH Applied Richard Henderson 4 participants 5 messages Sep 12, 2019 – Oct 17, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Fix sign-extension for SMLAL*

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

---
 target/arm/translate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/arm/translate.c +3 -1
index 34bb280e3d..fd2f0e3048 100644
@@ -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);
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#1 lore raw

Hello,

Quoted 6 lines · Richard Henderson

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

No more failures on my tests.

Thanks,

Laurent

Quoted 22 lines
---
 target/arm/translate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/arm/translate.c +3 -2
index 34bb280e3d..fd2f0e3048 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Richard Henderson
Quoted 5 lines · Richard Henderson

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

Quoted 20 lines
---
 target/arm/translate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/arm/translate.c +3 -1
index 34bb280e3d..fd2f0e3048 100644
@@ -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);
#3 lore raw
In reply to Richard Henderson

Ping.

Quoted 25 lines · Richard Henderson

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

---
 target/arm/translate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/arm/translate.c +3 -1
index 34bb280e3d..fd2f0e3048 100644
@@ -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);