py/misc: Fix fallback implementation of mp_popcount.
Tested using gcc 7.3.1 which does not have the popcount built-in and uses this fallback version. Without the fix, mpy-cross produces mpy files with corrupt RISC-V machine code. With the fix, mpy-cross output is correct. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -390,7 +390,7 @@ static inline uint32_t mp_popcount(uint32_t x) {
|
|||||||
x = x - ((x >> 1) & 0x55555555);
|
x = x - ((x >> 1) & 0x55555555);
|
||||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||||
return x * 0x01010101;
|
return (x * 0x01010101) >> 24;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user