Re:Popcount CPU instruction
by drfuchs on Sunday September 08, 2019 @11:04PM
(#20914899)
I about fell out of my chair when I saw gcc and clang both turn (u>>s)|(u<<(32-s)) into a single "rorl" (rotate right logical) instruction.
[ Parent
| on HN ]
Even pcc (on version 7 pdp-11 unix) knew that one.
That's a really easy one for compilers to detect. They start with the OR as the root and look backward to recognize the shifts and subtract.
Re:Popcount CPU instruction
by zzo38computer on Monday September 09, 2019 @02:26AM
(#20915658)
That I expected, actually. (It seems common enough to me, that it would be implemented like that.)