target-mips: Fix helper and tests for dot/cross-dot product instructions
PATCH 1/1 target-mips: Fix helper and tests for dot/cross-dot product instructions
From: Petar Jovanovic <[email protected]>
Helper function for dpa_w_ph, dpax_w_ph, dps_w_ph and dpsx_w_ph incorrectly defines halfword vector elements as unsigned values. This results in wrong output which is not triggered in the tests as they also follow this logic.
--- target-mips/dsp_helper.c | 2 +- tests/tcg/mips/mips32-dspr2/dpa_w_ph.c | 4 ++-- tests/tcg/mips/mips32-dspr2/dpax_w_ph.c | 17 +++++++++++++++++ tests/tcg/mips/mips32-dspr2/dps_w_ph.c | 17 +++++++++++++++++ tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c | 4 ++-- 5 files changed, 39 insertions(+), 5 deletions(-)
target-mips/dsp_helper.c +1 -1
@@ -2473,7 +2473,7 @@ DP_OB(dpsu_h_obr, 0, 24, 16, 8, 0, 24, 16, 8, 0); void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ CPUMIPSState *env) \ { \ - uint16_t rsB, rsA, rtB, rtA; \ + int16_t rsB, rsA, rtB, rtA; \ int32_t tempA, tempB; \ int64_t acc; \ \
tests/tcg/mips/mips32-dspr2/dpa_w_ph.c +2 -2
@@ -26,8 +26,8 @@ int main() ach =6 , acl =7 ; rs =0xFFFF00FF ; rt =0xFFFF0002 ; - resulth =0x05 ; - resultl =0xfffe0206 ; + resulth =0x06 ; + resultl =0x206 ; __asm ("mthi %0, $ac1\n\t" "mtlo %1, $ac1\n\t"
tests/tcg/mips/mips32-dspr2/dpax_w_ph.c +17 -0
@@ -23,5 +23,22 @@ int main()assert (ach == resulth);assert (acl == resultl); + ach =6 , acl =7 ; + rs =0xFFFF00FF ; + rt =0xFFFF0002 ; + resulth =0x05 ; + resultl =0xFFFFFF06 ; + __asm + ("mthi %0, $ac1\n\t" +"mtlo %1, $ac1\n\t" +"dpax.w.ph $ac1, %2, %3\n\t" +"mfhi %0, $ac1\n\t" +"mflo %1, $ac1\n\t" + :"+r" (ach),"+r" (acl) + :"r" (rs),"r" (rt) + ); +assert (ach == resulth); +assert (acl == resultl); +return 0 ; }
tests/tcg/mips/mips32-dspr2/dps_w_ph.c +17 -0
@@ -23,5 +23,22 @@ int main()assert (ach == resulth);assert (acl == resultl); + ach =6 , acl =7 ; + rs =0xFFFF00FF ; + rt =0xFFFF0002 ; + resulth =0x05 ; + resultl =0xFFFFFE08 ; + __asm + ("mthi %0, $ac1\n\t" +"mtlo %1, $ac1\n\t" +"dps.w.ph $ac1, %2, %3\n\t" +"mfhi %0, $ac1\n\t" +"mflo %1, $ac1\n\t" + :"+r" (ach),"+r" (acl) + :"r" (rs),"r" (rt) + ); +assert (ach == resulth); +assert (acl == resultl); +return 0 ; }
tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c +2 -2
@@ -9,8 +9,8 @@ int main() rs =0xBC0123AD ; rt =0x01643721 ; - resulth =0x04 ; - resultl =0xD751F050 ; + resulth =0x05 ; + resultl =0xE72F050 ; __asm ("mthi %0, $ac1\n\t" "mtlo %1, $ac1\n\t"
Signature · 1 line
1.7.5.4
Quoted 102 lines · Petar Jovanovic
From: Petar Jovanovic<[email protected]>
Helper function for
dpa_w_ph,dpax_w_ph,dps_w_phanddpsx_w_phincorrectly defines halfword vector elements as unsigned values. This results in wrong output which is not triggered in the tests as they also follow this logic.Signed-off-by Petar Jovanovic<[email protected]>--- target-mips/dsp_helper.c | 2 +- tests/tcg/mips/mips32-dspr2/dpa_w_ph.c | 4 ++-- tests/tcg/mips/mips32-dspr2/dpax_w_ph.c | 17 +++++++++++++++++ tests/tcg/mips/mips32-dspr2/dps_w_ph.c | 17 +++++++++++++++++ tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c | 4 ++-- 5 files changed, 39 insertions(+), 5 deletions(-)target-mips/dsp_helper.c +1
-1@@ -2473,7 +2473,7 @@ DP_OB(dpsu_h_obr, 0, 24, 16, 8, 0, 24, 16, 8, 0); void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ CPUMIPSState *env) \ { \ - uint16_t rsB, rsA, rtB, rtA; \ + int16_t rsB, rsA, rtB, rtA; \ int32_t tempA, tempB; \ int64_t acc; \ \tests/tcg/mips/mips32-dspr2/dpa_w_ph.c +2
-2@@ -26,8 +26,8 @@ int main() ach =6 , acl =7 ; rs =0xFFFF00FF ; rt =0xFFFF0002 ; - resulth =0x05 ; - resultl =0xfffe0206 ; + resulth =0x06 ; + resultl =0x206 ; __asm ("mthi %0, $ac1\n\t" "mtlo %1, $ac1\n\t"tests/tcg/mips/mips32-dspr2/dpax_w_ph.c +17
-0@@ -23,5 +23,22 @@ int main()assert (ach == resulth);assert (acl == resultl); + ach =6 , acl =7 ; + rs =0xFFFF00FF ; + rt =0xFFFF0002 ; + resulth =0x05 ; + resultl =0xFFFFFF06 ; + __asm + ("mthi %0, $ac1\n\t" +"mtlo %1, $ac1\n\t" +"dpax.w.ph $ac1, %2, %3\n\t" +"mfhi %0, $ac1\n\t" +"mflo %1, $ac1\n\t" + :"+r" (ach),"+r" (acl) + :"r" (rs),"r" (rt) + ); +assert (ach == resulth); +assert (acl == resultl); +return 0 ; }tests/tcg/mips/mips32-dspr2/dps_w_ph.c +17
-0@@ -23,5 +23,22 @@ int main()assert (ach == resulth);assert (acl == resultl); + ach =6 , acl =7 ; + rs =0xFFFF00FF ; + rt =0xFFFF0002 ; + resulth =0x05 ; + resultl =0xFFFFFE08 ; + __asm + ("mthi %0, $ac1\n\t" +"mtlo %1, $ac1\n\t" +"dps.w.ph $ac1, %2, %3\n\t" +"mfhi %0, $ac1\n\t" +"mflo %1, $ac1\n\t" + :"+r" (ach),"+r" (acl) + :"r" (rs),"r" (rt) + ); +assert (ach == resulth); +assert (acl == resultl); +return 0 ; }tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c +0
-0
tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c int main() · line 16
Quoted 10 lines
tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c +2
-2@@ -9,8 +9,8 @@ int main() rs =0xBC0123AD ; rt =0x01643721 ; - resulth =0x04 ; - resultl =0xD751F050 ; + resulth =0x05 ; + resultl =0xE72F050 ; __asm ("mthi %0, $ac1\n\t" "mtlo %1, $ac1\n\t"
Aurelien Jarno
AppliedQuoted 102 lines · Petar Jovanovic
From: Petar Jovanovic <[email protected]>
Helper function for
dpa_w_ph,dpax_w_ph,dps_w_phanddpsx_w_phincorrectly defines halfword vector elements as unsigned values. This results in wrong output which is not triggered in the tests as they also follow this logic.Signed-off-by Petar Jovanovic <[email protected]>--- target-mips/dsp_helper.c | 2 +- tests/tcg/mips/mips32-dspr2/dpa_w_ph.c | 4 ++-- tests/tcg/mips/mips32-dspr2/dpax_w_ph.c | 17 +++++++++++++++++ tests/tcg/mips/mips32-dspr2/dps_w_ph.c | 17 +++++++++++++++++ tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c | 4 ++-- 5 files changed, 39 insertions(+), 5 deletions(-)target-mips/dsp_helper.c +1
-1@@ -2473,7 +2473,7 @@ DP_OB(dpsu_h_obr, 0, 24, 16, 8, 0, 24, 16, 8, 0); void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ CPUMIPSState *env) \ { \ - uint16_t rsB, rsA, rtB, rtA; \ + int16_t rsB, rsA, rtB, rtA; \ int32_t tempA, tempB; \ int64_t acc; \ \tests/tcg/mips/mips32-dspr2/dpa_w_ph.c +2
-2@@ -26,8 +26,8 @@ int main() ach =6 , acl =7 ; rs =0xFFFF00FF ; rt =0xFFFF0002 ; - resulth =0x05 ; - resultl =0xfffe0206 ; + resulth =0x06 ; + resultl =0x206 ; __asm ("mthi %0, $ac1\n\t" "mtlo %1, $ac1\n\t"tests/tcg/mips/mips32-dspr2/dpax_w_ph.c +17
-0@@ -23,5 +23,22 @@ int main()assert (ach == resulth);assert (acl == resultl); + ach =6 , acl =7 ; + rs =0xFFFF00FF ; + rt =0xFFFF0002 ; + resulth =0x05 ; + resultl =0xFFFFFF06 ; + __asm + ("mthi %0, $ac1\n\t" +"mtlo %1, $ac1\n\t" +"dpax.w.ph $ac1, %2, %3\n\t" +"mfhi %0, $ac1\n\t" +"mflo %1, $ac1\n\t" + :"+r" (ach),"+r" (acl) + :"r" (rs),"r" (rt) + ); +assert (ach == resulth); +assert (acl == resultl); +return 0 ; }tests/tcg/mips/mips32-dspr2/dps_w_ph.c +17
-0@@ -23,5 +23,22 @@ int main()assert (ach == resulth);assert (acl == resultl); + ach =6 , acl =7 ; + rs =0xFFFF00FF ; + rt =0xFFFF0002 ; + resulth =0x05 ; + resultl =0xFFFFFE08 ; + __asm + ("mthi %0, $ac1\n\t" +"mtlo %1, $ac1\n\t" +"dps.w.ph $ac1, %2, %3\n\t" +"mfhi %0, $ac1\n\t" +"mflo %1, $ac1\n\t" + :"+r" (ach),"+r" (acl) + :"r" (rs),"r" (rt) + ); +assert (ach == resulth); +assert (acl == resultl); +return 0 ; }tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c +0
-0
tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c int main() · line 16
Quoted 10 lines
tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c +2
-2@@ -9,8 +9,8 @@ int main() rs =0xBC0123AD ; rt =0x01643721 ; - resulth =0x04 ; - resultl =0xD751F050 ; + resulth =0x05 ; + resultl =0xE72F050 ; __asm ("mthi %0, $ac1\n\t" "mtlo %1, $ac1\n\t"
Thanks, applied.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net