diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2015-04-27 08:53:46 +0000 |
---|---|---|
committer | Mark Mendell <mark.p.mendell@intel.com> | 2015-04-27 20:06:50 -0400 |
commit | 0d22184ec9e5b1e958c031ac92c7f053de3a13a2 (patch) | |
tree | 4055eda9986916dc86b39d023082a57e60c804f4 /runtime/utils.h | |
parent | 97c96f5aab22f75dd54089bdc194588a4b5a2e8d (diff) | |
download | art-0d22184ec9e5b1e958c031ac92c7f053de3a13a2.tar.gz art-0d22184ec9e5b1e958c031ac92c7f053de3a13a2.tar.bz2 art-0d22184ec9e5b1e958c031ac92c7f053de3a13a2.zip |
Revert "Revert "[optimizing] Replace FP divide by power of 2""
This reverts commit 067cae2c86627d2edcf01b918ee601774bc76aeb.
Change-Id: Iaaa8772500ea7d3dce6ae0829dc0dc3bbc9c14ca
Diffstat (limited to 'runtime/utils.h')
-rw-r--r-- | runtime/utils.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/utils.h b/runtime/utils.h index 853fa08251..eaafcf0a64 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -300,6 +300,18 @@ static inline int WhichPowerOf2(T x) { return CTZ(x); } +// Return whether x / divisor == x * (1.0f / divisor), for every float x. +static constexpr bool CanDivideByReciprocalMultiplyFloat(int32_t divisor) { + // True, if the most significant bits of divisor are 0. + return ((divisor & 0x7fffff) == 0); +} + +// Return whether x / divisor == x * (1.0 / divisor), for every double x. +static constexpr bool CanDivideByReciprocalMultiplyDouble(int64_t divisor) { + // True, if the most significant bits of divisor are 0. + return ((divisor & ((UINT64_C(1) << 52) - 1)) == 0); +} + template<typename T> static constexpr int POPCOUNT(T x) { return (sizeof(T) == sizeof(uint32_t)) |