Reviewers: danno, Paul Lind, palfia, kisg, dusmil,
Description:
MIPS: Fix clz implementation of the simulator.
BUG=
Please review this at https://codereview.chromium.org/166273020/
SVN Base: https://github.com/v8/v8.git@gbl
Affected files (+5, -1 lines):
M src/mips/simulator-mips.cc
Index: src/mips/simulator-mips.cc
diff --git a/src/mips/simulator-mips.cc b/src/mips/simulator-mips.cc
index
10417d573cfa2ae8b1f2e06587c2615e67cd2ef6..efce887c2e6d4e5f7ef21e07246b1118114ec6de
100644
--- a/src/mips/simulator-mips.cc
+++ b/src/mips/simulator-mips.cc
@@ -1926,7 +1926,11 @@ void Simulator::ConfigureTypeRegister(Instruction*
instr,
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.