[Python-checkins] bpo-29882: _Py_popcount32() doesn't need 64x64 multiply (GH-30774)
vstinner
webhook-mailer at python.org
Fri Jan 21 18:54:53 EST 2022
https://github.com/python/cpython/commit/cd8de40b3b10311de2db7b90abdf80af9e35535f
commit: cd8de40b3b10311de2db7b90abdf80af9e35535f
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-01-22T00:54:42+01:00
summary:
bpo-29882: _Py_popcount32() doesn't need 64x64 multiply (GH-30774)
32x32 bits multiply is enough for _Py_popcount32().
files:
M Include/internal/pycore_bitutils.h
diff --git a/Include/internal/pycore_bitutils.h b/Include/internal/pycore_bitutils.h
index e4aa7a3d0d056..3fd70b0e417c1 100644
--- a/Include/internal/pycore_bitutils.h
+++ b/Include/internal/pycore_bitutils.h
@@ -125,7 +125,7 @@ _Py_popcount32(uint32_t x)
// Put count of each 8 bits into those 8 bits
x = (x + (x >> 4)) & M4;
// Sum of the 4 byte counts
- return (uint32_t)((uint64_t)x * (uint64_t)SUM) >> 24;
+ return (x * SUM) >> 24;
#endif
}
More information about the Python-checkins
mailing list