3 ms·
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.
by drfuchs 7y ago
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.
- ncmncm 7y agoEven pcc (on version 7 pdp-11 unix) knew that one.
- neerajsi 7y agoThat'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.
- zzo38computer 7y agoThat I expected, actually. (It seems common enough to me, that it would be implemented like that.)