Revision: 19517
Author:   [email protected]
Date:     Thu Feb 20 17:18:57 2014 UTC
Log:      MIPS: Fix clz implementation of the simulator.

BUG=
[email protected]

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

Patch from Balazs Kilvady <[email protected]>.
http://code.google.com/p/v8/source/detail?r=19517

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

=======================================
--- /branches/bleeding_edge/src/mips/simulator-mips.cc Fri Jan 31 00:36:19 2014 UTC +++ /branches/bleeding_edge/src/mips/simulator-mips.cc Thu Feb 20 17:18:57 2014 UTC
@@ -1926,7 +1926,11 @@
           alu_out = rs_u * rt_u;  // Only the lower 32 bits are kept.
           break;
         case CLZ:
-          alu_out = __builtin_clz(rs_u);
+ // MIPS32 spec: If no bits were set in GPR rs, the result written to
+          // GPR rd is 32.
+          // GCC __builtin_clz: If input is 0, the result is undefined.
+          alu_out =
+              rs_u == 0 ? 32 : CompilerIntrinsics::CountLeadingZeros(rs_u);
           break;
         default:
           UNREACHABLE();

--
--
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