Skip to content

Commit

Permalink
target-mips: fix for incorrect multiplication with MULQ_S.PH
Browse files Browse the repository at this point in the history
The change corrects sign-related issue with MULQ_S.PH. It also includes
extension to the already existing test which will trigger the issue.

Signed-off-by: Petar Jovanovic <[email protected]>
Signed-off-by: Aurelien Jarno <[email protected]>
  • Loading branch information
petar-jovanovic authored and aurel32 committed Feb 23, 2013
1 parent d2123a0 commit 9c19eb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion target-mips/dsp_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ static inline int32_t mipsdsp_sat16_mul_q15_q15(uint16_t a, uint16_t b,
temp = 0x7FFF0000;
set_DSPControl_overflow_flag(1, 21, env);
} else {
temp = ((uint32_t)a * (uint32_t)b);
temp = (int16_t)a * (int16_t)b;
temp = temp << 1;
}

Expand Down
15 changes: 15 additions & 0 deletions tests/tcg/mips/mips32-dspr2/mulq_s_ph.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ int main()
int rd, rs, rt, dsp;
int result, resultdsp;

rs = 0x80000000;
rt = 0x0ffc0000;
result = 0xF0040000;
resultdsp = 0;

__asm
("mulq_s.ph %0, %2, %3\n\t"
"rddsp %1\n\t"
: "=r"(rd), "=r"(dsp)
: "r"(rs), "r"(rt)
);
dsp = (dsp >> 21) & 0x01;
assert(rd == result);
assert(dsp == resultdsp);

rs = 0x80001234;
rt = 0x80004321;
result = 0x7FFF098B;
Expand Down

0 comments on commit 9c19eb1

Please sign in to comment.