MathUtil: Generify IsPow2

This will allow it to also be used in the AArch64 emitter.
This commit is contained in:
Lioncash 2018-03-23 09:50:09 -04:00
parent e88cc33a29
commit 79f40fb8d7
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7

View File

@ -49,9 +49,10 @@ constexpr T Clamp(const T val, const T& min, const T& max)
return std::max(min, std::min(max, val));
}
constexpr bool IsPow2(u32 imm)
template <typename T>
constexpr bool IsPow2(T imm)
{
return (imm & (imm - 1)) == 0;
return imm > 0 && (imm & (imm - 1)) == 0;
}
// The most significant bit of the fraction is an is-quiet bit on all architectures we care about.