Revision: 14937
Author: [email protected]
Date: Tue Jun 4 08:39:56 2013
Log: Replace log2 with MostSignificantBit
[email protected]
Review URL: https://chromiumcodereview.appspot.com/15994015
http://code.google.com/p/v8/source/detail?r=14937
Modified:
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/utils.h
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Jun 4
05:26:39 2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Jun 4
08:39:56 2013
@@ -2328,14 +2328,11 @@
if (right_upper < 0) right_upper = ~right_upper;
if (right_lower < 0) right_lower = ~right_lower;
- // Find the highest used bit.
- int high = static_cast<int>(log2(left_upper));
- high = Max(high, static_cast<int>(log2(left_lower)));
- high = Max(high, static_cast<int>(log2(right_upper)));
- high = Max(high, static_cast<int>(log2(right_lower)));
+ int high = MostSignificantBit(
+ left_upper | left_lower | right_upper | right_lower);
int64_t limit = 1;
- limit <<= high + 1;
+ limit <<= high;
int32_t min = (left()->range()->CanBeNegative() ||
right()->range()->CanBeNegative())
? static_cast<int32_t>(-limit) : 0;
=======================================
--- /branches/bleeding_edge/src/utils.h Wed May 29 05:42:04 2013
+++ /branches/bleeding_edge/src/utils.h Tue Jun 4 08:39:56 2013
@@ -84,6 +84,25 @@
return bits;
return 0;
}
+
+
+inline int MostSignificantBit(uint32_t x) {
+ static const int msb4[] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4,
4};
+ int nibble = 0;
+ if (x & 0xffff0000) {
+ nibble += 16;
+ x >>= 16;
+ }
+ if (x & 0xff00) {
+ nibble += 8;
+ x >>= 8;
+ }
+ if (x & 0xf0) {
+ nibble += 4;
+ x >>= 4;
+ }
+ return nibble + msb4[x];
+}
// Magic numbers for integer division.
--
--
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.