3 ms·
Especially on microcontrollers or DSPs this could be quite useful. I have never seen a C-compiler able to infer a bit rotation instruction, though.
by kken 8y ago
Especially on microcontrollers or DSPs this could be quite useful. I have never seen a C-compiler able to infer a bit rotation instruction, though.
- pm215 8y agogcc will recognize the usual rotate idiom: unsigned int rotv(unsigned int x, int c) { return (x << c) | (x >> (32 - c)); } On x86 it emits a rol instruction, for instance.
- jlarcombe 8y agoThe original ARM C compiler ('Norcroft') did this a lot as I recall. Relevant to the original post here of course, as the original spec was a processor that could interpret BBC BASIC as fast as hand optimised 6502 assembler.