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

Unified Diff: src/utils.h

Issue 1056543002: [turbofan][arm64] Match add with shifted operand for mult by a power of 2 plus 1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index 5c7afbec20e494808c7531789e0818638bdf9954..881d8bffabe9a58387e5b723c64db66a125da994 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -67,6 +67,41 @@ inline int WhichPowerOf2(uint32_t x) {
}
+// X must be a power of 2. Returns the number of trailing zeros.
+inline int WhichPowerOf2_64(uint64_t x) {
+ DCHECK(base::bits::IsPowerOfTwo64(x));
+ int bits = 0;
+#ifdef DEBUG
+ uint64_t original_x = x;
+#endif
+ if (x >= 0x100000000L) {
+ bits += 32;
+ x >>= 32;
+ }
+ if (x >= 0x10000) {
+ bits += 16;
+ x >>= 16;
+ }
+ if (x >= 0x100) {
+ bits += 8;
+ x >>= 8;
+ }
+ if (x >= 0x10) {
+ bits += 4;
+ x >>= 4;
+ }
+ switch (x) {
+ default: UNREACHABLE();
+ case 8: bits++; // Fall through.
+ case 4: bits++; // Fall through.
+ case 2: bits++; // Fall through.
+ case 1: break;
+ }
+ DCHECK_EQ(1L << bits, original_x);
+ return bits;
+}
+
+
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;
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698