target-arm: Fix VQDMLSL
cover target-arm: Fix VQDMLSL
This patch series fixes the Neon VQDMLSL instruction, which was incorrectly doing the negation step before saturation rather than afterwards. Patch 1 is a minor cleanup to the affected code area before patch 2 which is the fix proper.
Tested with the usual random instruction sequences.
Peter Maydell (2):
target-arm: Refactor handling of VQDMULL
target-arm: Fix Neon VQDMLSL instruction
target-arm/translate.c | 38 ++++++++++++++++++++------------------ 1 files changed, 20 insertions(+), 18 deletions(-)
PATCH 1/2 target-arm: Refactor handling of VQDMULL
Refactor the handling of VQDMULL so that it is dealt with in its own if() case rather than together with the accumulating instructions.
--- target-arm/translate.c | 16 ++++++---------- 1 files changed, 6 insertions(+), 10 deletions(-)
target-arm/translate.c +6 -10
@@ -5129,16 +5129,16 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)default :/* 15 is RESERVED. */ return 1 ; } -if (op ==5 || op ==13 || (op >=8 && op <=11 )) { +if (op ==13 ) { +/* VQDMULL */ +gen_neon_addl_saturate (cpu_V0, cpu_V0, size); +neon_store_reg64 (cpu_V0, rd + pass); + }else if (op ==5 || (op >=8 && op <=11 )) {/* Accumulate. */ if (op ==10 || op ==11 ) {gen_neon_negl (cpu_V0, size); } - -if (op !=13 ) { -neon_load_reg64 (cpu_V1, rd + pass); - } - +neon_load_reg64 (cpu_V1, rd + pass);switch (op) {case 5 :case 8 :case 10 :/* VABAL, VMLAL, VMLSL */ gen_neon_addl (size);
@@ -5147,10 +5147,6 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)gen_neon_addl_saturate (cpu_V0, cpu_V0, size);gen_neon_addl_saturate (cpu_V0, cpu_V1, size);break ; -/* Fall through. */ -case 13 :/* VQDMULL */ -gen_neon_addl_saturate (cpu_V0, cpu_V0, size); -break ;default :abort (); }
Signature · 1 line
1.7.1
PATCH 2/2 target-arm: Fix Neon VQDMLSL instruction
In reply to Peter MaydellFor VQDMLSL, negation has to occur after saturation, not before.
--- target-arm/translate.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)
target-arm/translate.c +14 -8
@@ -5135,16 +5135,19 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)neon_store_reg64 (cpu_V0, rd + pass); }else if (op ==5 || (op >=8 && op <=11 )) {/* Accumulate. */ -if (op ==10 || op ==11 ) { -gen_neon_negl (cpu_V0, size); - }neon_load_reg64 (cpu_V1, rd + pass);switch (op) { -case 5 :case 8 :case 10 :/* VABAL, VMLAL, VMLSL */ +case 10 :/* VMLSL */ +gen_neon_negl (cpu_V0, size); +/* Fall through */ +case 5 :case 8 :/* VABAL, VMLAL */ gen_neon_addl (size);break ;case 9 :case 11 :/* VQDMLAL, VQDMLSL */ gen_neon_addl_saturate (cpu_V0, cpu_V0, size); +if (op ==11 ) { +gen_neon_negl (cpu_V0, size); + }gen_neon_addl_saturate (cpu_V0, cpu_V1, size);break ;default :
@@ -5282,18 +5285,21 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) tmp2 = tmp4; }gen_neon_mull (cpu_V0, tmp, tmp2, size, u); -if (op ==6 || op ==7 ) { -gen_neon_negl (cpu_V0, size); - }if (op !=11 ) {neon_load_reg64 (cpu_V1, rd + pass); }switch (op) { -case 2 :case 6 : +case 6 : +gen_neon_negl (cpu_V0, size); +/* Fall through */ +case 2 :gen_neon_addl (size);break ;case 3 :case 7 :gen_neon_addl_saturate (cpu_V0, cpu_V0, size); +if (op ==7 ) { +gen_neon_negl (cpu_V0, size); + }gen_neon_addl_saturate (cpu_V0, cpu_V1, size);break ;case 10 :
Signature · 1 line
1.7.1
Quoted 5 lines · Peter Maydell
This patch series fixes the Neon VQDMLSL instruction, which was incorrectly doing the negation step before saturation rather than afterwards. Patch 1 is a minor cleanup to the affected code area before patch 2 which is the fix proper.
Quoted 9 lines
Tested with the usual random instruction sequences.
Peter Maydell (2):
target-arm: Refactor handling of VQDMULL
target-arm: Fix Neon VQDMLSL instructiontarget-arm/translate.c | 38 ++++++++++++++++++++------------------ 1 files changed, 20 insertions(+), 18 deletions(-)
Thanks, both applied.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net