target-mips: fix mipsdsp_mul_q15_q15 and tests for MAQ_SA_Q_PHL/PHR
PATCH 1/1 target-mips: fix mipsdsp_mul_q15_q15 and tests for MAQ_SA_Q_PHL/PHR
From: Petar Jovanovic <[email protected]>
The operands for MAQ_SA_W.PHL/MAQ_SA_W.PHR must in specified format. Otherwise, the results are unpredictable. Once the operands were corrected in the tests (part of this change), a bug in mipsdsp_mul_q15_q15 became visible.
This change corrects the tests for MAQ_SA_W.PHL/MAQ_SA_W.PHR and fixes sign-related issue in mipsdsp_mul_q15_q15. It also removes unnecessary comment.
--- target-mips/dsp_helper.c | 14 +------------- tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c | 12 ++++++------ tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 31 deletions(-)
target-mips/dsp_helper.c +1 -13
@@ -269,18 +269,6 @@ static inline int32_t mipsdsp_sat32_acc_q31(int32_t acc, int32_t a, temp31 = (temp_sum >>31 ) &0x01 ; result = temp_sum &0xFFFFFFFF ; -/* FIXME -This sat function may wrong, because user manual wrote: -temp127..0 ← temp + ( (signA) || a31..0 -if ( temp32 ≠ temp31 ) then -if ( temp32 = 0 ) then -temp31..0 ← 0x80000000 -else -temp31..0 ← 0x7FFFFFFF -endif -DSPControlouflag:16+acc ← 1 -endif -*/ if (temp32 != temp31) {if (temp32 ==0 ) { result =0x7FFFFFFF ;
@@ -578,7 +566,7 @@ static inline int32_t mipsdsp_mul_q15_q15(int32_t ac, uint16_t a, uint16_t b, temp =0x7FFFFFFF ;set_DSPControl_overflow_flag (1 ,16 + ac, env); }else { - temp = ((uint32_t )a * (uint32_t )b) <<1 ; + temp = ((int16_t )a * (int16_t )b) <<1 ; }return temp;
tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c +6 -6
@@ -10,12 +10,12 @@ int main()int resulth, resultl;int resdsp; - achi =0x05 ; - acli =0xB4CB ; + achi =0x00000000 ; + acli =0x0000B4CB ; rs =0xFF060000 ; rt =0xCB000000 ; - resulth =0x00 ; - resultl =0x7FFFFFFF ; + resulth =0x00000000 ; + resultl =0x006838CB ; __asm ("mthi %2, $ac1\n\t"
@@ -29,8 +29,8 @@ int main()assert (resulth == acho);assert (resultl == aclo); - achi =0x06 ; - acli =0xB4CB ; + achi =0x00000000 ; + acli =0x0000B4CB ; rs =0x80000000 ; rt =0x80000000 ; resulth =0x00 ;
tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c +12 -12
@@ -10,12 +10,12 @@ int main()int resulth, resultl;int resdsp; - achi =0x05 ; - acli =0xB4CB ; - rs =0xFF06 ; - rt =0xCB00 ; - resulth =0x00 ; - resultl =0x7FFFFFFF ; + achi =0x00000000 ; + acli =0x0000B4CB ; + rs =0x0000FF06 ; + rt =0x0000CB00 ; + resulth =0x00000000 ; + resultl =0x006838CB ; __asm ("mthi %2, $ac1\n\t"
@@ -29,12 +29,12 @@ int main()assert (resulth == acho);assert (resultl == aclo); - achi =0x06 ; - acli =0xB4CB ; - rs =0x8000 ; - rt =0x8000 ; - resulth =0x00 ; - resultl =0x7fffffff ; + achi =0x00000000 ; + acli =0x0000B4CB ; + rs =0x00008000 ; + rt =0x00008000 ; + resulth =0x00000000 ; + resultl =0x7FFFFFFF ; resdsp =0x01 ; __asm
Signature · 1 line
1.7.9.5
There is a typo in the subject, it should say:
"target-mips: fix mipsdsp_mul_q15_q15 and tests for MAQ_SA_W_PHL/PHR"
Petar
________________________________________
From: Petar Jovanovic [[email protected]]
Sent: Monday, April 15, 2013 1:54 PM
To: [email protected]
Cc: Petar Jovanovic; [email protected]
Subject: [PATCH] target-mips: fix mipsdsp_mul_q15_q15 and tests for MAQ_SA_Q_PHL/PHR
From: Petar Jovanovic <[email protected]>
The operands for MAQ_SA_W.PHL/MAQ_SA_W.PHR must in specified format. Otherwise, the results are unpredictable. Once the operands were corrected in the tests (part of this change), a bug in mipsdsp_mul_q15_q15 became visible.
This change corrects the tests for MAQ_SA_W.PHL/MAQ_SA_W.PHR and fixes sign-related issue in mipsdsp_mul_q15_q15. It also removes unnecessary comment.
--- target-mips/dsp_helper.c | 14 +------------- tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c | 12 ++++++------ tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 31 deletions(-)
target-mips/dsp_helper.c +1 -13
@@ -269,18 +269,6 @@ static inline int32_t mipsdsp_sat32_acc_q31(int32_t acc, int32_t a, temp31 = (temp_sum >>31 ) &0x01 ; result = temp_sum &0xFFFFFFFF ; -/* FIXME -This sat function may wrong, because user manual wrote: -temp127..0 ← temp + ( (signA) || a31..0 -if ( temp32 ≠ temp31 ) then -if ( temp32 = 0 ) then -temp31..0 ← 0x80000000 -else -temp31..0 ← 0x7FFFFFFF -endif -DSPControlouflag:16+acc ← 1 -endif -*/ if (temp32 != temp31) {if (temp32 ==0 ) { result =0x7FFFFFFF ;
@@ -578,7 +566,7 @@ static inline int32_t mipsdsp_mul_q15_q15(int32_t ac, uint16_t a, uint16_t b, temp =0x7FFFFFFF ;set_DSPControl_overflow_flag (1 ,16 + ac, env); }else { - temp = ((uint32_t )a * (uint32_t )b) <<1 ; + temp = ((int16_t )a * (int16_t )b) <<1 ; }return temp;
tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c +6 -6
@@ -10,12 +10,12 @@ int main()int resulth, resultl;int resdsp; - achi =0x05 ; - acli =0xB4CB ; + achi =0x00000000 ; + acli =0x0000B4CB ; rs =0xFF060000 ; rt =0xCB000000 ; - resulth =0x00 ; - resultl =0x7FFFFFFF ; + resulth =0x00000000 ; + resultl =0x006838CB ; __asm ("mthi %2, $ac1\n\t"
@@ -29,8 +29,8 @@ int main()assert (resulth == acho);assert (resultl == aclo); - achi =0x06 ; - acli =0xB4CB ; + achi =0x00000000 ; + acli =0x0000B4CB ; rs =0x80000000 ; rt =0x80000000 ; resulth =0x00 ;
tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c +12 -12
@@ -10,12 +10,12 @@ int main()int resulth, resultl;int resdsp; - achi =0x05 ; - acli =0xB4CB ; - rs =0xFF06 ; - rt =0xCB00 ; - resulth =0x00 ; - resultl =0x7FFFFFFF ; + achi =0x00000000 ; + acli =0x0000B4CB ; + rs =0x0000FF06 ; + rt =0x0000CB00 ; + resulth =0x00000000 ; + resultl =0x006838CB ; __asm ("mthi %2, $ac1\n\t"
@@ -29,12 +29,12 @@ int main()assert (resulth == acho);assert (resultl == aclo); - achi =0x06 ; - acli =0xB4CB ; - rs =0x8000 ; - rt =0x8000 ; - resulth =0x00 ; - resultl =0x7fffffff ; + achi =0x00000000 ; + acli =0x0000B4CB ; + rs =0x00008000 ; + rt =0x00008000 ; + resulth =0x00000000 ; + resultl =0x7FFFFFFF ; resdsp =0x01 ; __asm
--
1.7.9.5
Aurelien Jarno
AppliedQuoted 11 lines · Petar Jovanovic
From: Petar Jovanovic <[email protected]>
The operands for MAQ_SA_W.PHL/MAQ_SA_W.PHR must in specified format. Otherwise, the results are unpredictable. Once the operands were corrected in the tests (part of this change), a bug in
mipsdsp_mul_q15_q15became visible.This change corrects the tests for MAQ_SA_W.PHL/MAQ_SA_W.PHR and fixes sign-related issue in
mipsdsp_mul_q15_q15. It also removes unnecessary comment.
Quoted 6 lines
Signed-off-by Petar Jovanovic <[email protected]>--- target-mips/dsp_helper.c | 14 +------------- tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c | 12 ++++++------ tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 31 deletions(-)
Thanks, applied (with the subject tweaked).
Quoted 111 lines
target-mips/dsp_helper.c +1
-13@@ -269,18 +269,6 @@ static inline int32_t mipsdsp_sat32_acc_q31(int32_t acc, int32_t a, temp31 = (temp_sum >>31 ) &0x01 ; result = temp_sum &0xFFFFFFFF ; -/* FIXME -This sat function may wrong, because user manual wrote: -temp127..0 ← temp + ( (signA) || a31..0 -if ( temp32 ≠ temp31 ) then -if ( temp32 = 0 ) then -temp31..0 ← 0x80000000 -else -temp31..0 ← 0x7FFFFFFF -endif -DSPControlouflag:16+acc ← 1 -endif -*/ if (temp32 != temp31) {if (temp32 ==0 ) { result =0x7FFFFFFF ;@@ -578,7 +566,7 @@ static inline int32_t mipsdsp_mul_q15_q15(int32_t ac, uint16_t a, uint16_t b, temp =0x7FFFFFFF ;set_DSPControl_overflow_flag (1 ,16 + ac, env); }else { - temp = ((uint32_t )a * (uint32_t )b) <<1 ; + temp = ((int16_t )a * (int16_t )b) <<1 ; }return temp;tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c +6
-6@@ -10,12 +10,12 @@ int main()int resulth, resultl;int resdsp; - achi =0x05 ; - acli =0xB4CB ; + achi =0x00000000 ; + acli =0x0000B4CB ; rs =0xFF060000 ; rt =0xCB000000 ; - resulth =0x00 ; - resultl =0x7FFFFFFF ; + resulth =0x00000000 ; + resultl =0x006838CB ; __asm ("mthi %2, $ac1\n\t"@@ -29,8 +29,8 @@ int main()assert (resulth == acho);assert (resultl == aclo); - achi =0x06 ; - acli =0xB4CB ; + achi =0x00000000 ; + acli =0x0000B4CB ; rs =0x80000000 ; rt =0x80000000 ; resulth =0x00 ;tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c +12
-12@@ -10,12 +10,12 @@ int main()int resulth, resultl;int resdsp; - achi =0x05 ; - acli =0xB4CB ; - rs =0xFF06 ; - rt =0xCB00 ; - resulth =0x00 ; - resultl =0x7FFFFFFF ; + achi =0x00000000 ; + acli =0x0000B4CB ; + rs =0x0000FF06 ; + rt =0x0000CB00 ; + resulth =0x00000000 ; + resultl =0x006838CB ; __asm ("mthi %2, $ac1\n\t"@@ -29,12 +29,12 @@ int main()assert (resulth == acho);assert (resultl == aclo); - achi =0x06 ; - acli =0xB4CB ; - rs =0x8000 ; - rt =0x8000 ; - resulth =0x00 ; - resultl =0x7fffffff ; + achi =0x00000000 ; + acli =0x0000B4CB ; + rs =0x00008000 ; + rt =0x00008000 ; + resulth =0x00000000 ; + resultl =0x7FFFFFFF ; resdsp =0x01 ; __asmSignature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net