Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Unified Diff: src/mips/simulator-mips.cc

Issue 10870049: MIPS: Fix rounding in Uint8ClampedArray setter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/simulator-mips.cc
diff --git a/src/mips/simulator-mips.cc b/src/mips/simulator-mips.cc
index 66d0da71fa4260e086b77b99f8f3773466db5d44..77d64f0782a3c832faa3be86a505b3633d7a1386 100644
--- a/src/mips/simulator-mips.cc
+++ b/src/mips/simulator-mips.cc
@@ -2068,10 +2068,15 @@ void Simulator::DecodeTypeRegister(Instruction* instr) {
// Rounding modes are not yet supported.
ASSERT((FCSR_ & 3) == 0);
// In rounding mode 0 it should behave like ROUND.
- case ROUND_W_D: // Round double to word.
+ case ROUND_W_D: // Round double to word (round half to even).
{
double rounded = fs > 0 ? floor(fs + 0.5) : ceil(fs - 0.5);
ulan 2012/08/24 07:21:07 Why not just do floor(fs + 0.5) for both positive
palfia 2012/08/24 23:57:29 Done.
int32_t result = static_cast<int32_t>(rounded);
+ if ((result & 1) != 0 && result - fs == 0.5) {
ulan 2012/08/24 07:21:07 This doesn't handle the case when fs is negative,
palfia 2012/08/24 23:57:29 Using floor(fs + 0.5) above for negative numbers t
ulan 2012/08/27 07:23:26 Yep, thanks for fixing it. :)
+ // If the number is halfway between two integers,
+ // round to the even one.
+ result--;
+ }
set_fpu_register(fd_reg, result);
if (set_fcsr_round_error(fs, rounded)) {
set_fpu_register(fd_reg, kFPUInvalidResult);
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698