The function intmath.leastSigBit is ambiguous given
its name. It does not return the value of the least
significant bit, or the position of the least significant
set bit, but instead 2 to the power of the position of
the least significant set bit. It has thereby been removed
and the function intmath.isPowerOf2 has been refactored to
not require intmath.leastSigBit.
Change-Id: I22479c666cdd059865b8c73b70b5388f98a4584d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22583
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
return true;
}
-template <class T>
-inline T
-leastSigBit(const T& n)
-{
- return n & ~(n - 1);
-}
-
-template <class T>
-inline bool
-isPowerOf2(const T& n)
-{
- return n != 0 && leastSigBit(n) == n;
-}
-
inline uint64_t
power(uint32_t n, uint32_t e)
{
return floorLog2(n - (T)1) + 1;
}
+template <class T>
+inline bool
+isPowerOf2(const T& n)
+{
+ return n != 0 && floorLog2(n) == ceilLog2(n);
+}
+
template <class T>
inline T
floorPow2(const T& n)