Revision: 16982
Author:   [email protected]
Date:     Fri Sep 27 10:42:51 2013 UTC
Log:      MIPS: Fix simulator divide for overflow case.

TEST=mjsunit/div-mul-minus-one.js
BUG=
[email protected]

Review URL: https://codereview.chromium.org/24956002

Patch from Paul Lind <[email protected]>.
http://code.google.com/p/v8/source/detail?r=16982

Modified:
 /branches/bleeding_edge/src/mips/simulator-mips.cc

=======================================
--- /branches/bleeding_edge/src/mips/simulator-mips.cc Tue Aug 27 23:02:35 2013 UTC +++ /branches/bleeding_edge/src/mips/simulator-mips.cc Fri Sep 27 10:42:51 2013 UTC
@@ -2274,9 +2274,13 @@
           break;
         case DIV:
// Divide by zero and overflow was not checked in the configuration - // step - div and divu do not raise exceptions. On division by 0 and
-          // on overflow (INT_MIN/-1), the result will be UNPREDICTABLE.
-          if (rt != 0 && !(rs == INT_MIN && rt == -1)) {
+          // step - div and divu do not raise exceptions. On division by 0
+          // the result will be UNPREDICTABLE. On overflow (INT_MIN/-1),
+          // return INT_MIN which is what the hardware does.
+          if (rs == INT_MIN && rt == -1) {
+            set_register(LO, INT_MIN);
+            set_register(HI, 0);
+          } else if (rt != 0) {
             set_register(LO, rs / rt);
             set_register(HI, rs % rt);
           }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to