From dd6801f75ca7d151efbaf81b5ef4583dbf8459ad Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Wed, 17 Feb 2021 14:39:55 +0000 Subject: [PATCH] base: Remove duplicate isPow2 helper This is already defined as isPowerOf2 in src/base/intmath.hh and it is currently unused Change-Id: I50b5d344e234fe1d4f1f85186686440773a209e3 Signed-off-by: Giacomo Travaglini Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41533 Tested-by: kokoro --- src/base/bitfield.hh | 8 -------- src/base/bitfield.test.cc | 18 ------------------ src/base/intmath.test.cc | 2 ++ 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/src/base/bitfield.hh b/src/base/bitfield.hh index 470941ac4b..9dc7722998 100644 --- a/src/base/bitfield.hh +++ b/src/base/bitfield.hh @@ -303,14 +303,6 @@ findLsbSet(uint64_t val) return lsb; } -/** - * Checks if a number is a power of two, or zero. - * - * @ingroup api_bitfield - */ -template -constexpr inline bool isPow2(T v) { return (v & (v - 1)) == (T)0; } - /** * Returns the number of set ones in the provided value. * PD algorithm from diff --git a/src/base/bitfield.test.cc b/src/base/bitfield.test.cc index 51c316e54d..8097415217 100644 --- a/src/base/bitfield.test.cc +++ b/src/base/bitfield.test.cc @@ -290,24 +290,6 @@ TEST(BitfieldTest, FindLsbZero) EXPECT_EQ(64, findLsbSet(0)); } -/* The following tests a simple function that verifies whether a value is a - * a power of two or not. - */ -TEST(BitfieldTest, IsPow2) -{ - EXPECT_TRUE(isPow2(32)); -} - -TEST(BitfieldTest, IsNotPow2) -{ - EXPECT_FALSE(isPow2(36)); -} - -TEST(BitfieldTest, IsPow2Zero) -{ - EXPECT_TRUE(isPow2(0)); -} - /* * The following tests "popCount(X)". popCount counts the number of bits set to * one. diff --git a/src/base/intmath.test.cc b/src/base/intmath.test.cc index 4e88b00886..e985a1b5d7 100644 --- a/src/base/intmath.test.cc +++ b/src/base/intmath.test.cc @@ -33,10 +33,12 @@ TEST(IntmathTest, isPowerOf2) { EXPECT_TRUE(isPowerOf2(1)); + EXPECT_TRUE(isPowerOf2(32)); EXPECT_TRUE(isPowerOf2(65536)); EXPECT_TRUE(isPowerOf2(131072)); EXPECT_TRUE(isPowerOf2(262144)); EXPECT_FALSE(isPowerOf2(0)); + EXPECT_FALSE(isPowerOf2(36)); EXPECT_FALSE(isPowerOf2(2521)); EXPECT_FALSE(isPowerOf2(1679616)); }