3 ms·
> Honest shift-and-mask operations on unsigned machine words are always better, if you absolutely must pack bitwise Now you go ahead and teach GCC to use the a
by dmitrygr 5y ago
> Honest shift-and-mask operations on unsigned machine words are always better, if you absolutely must pack bitwise
Now you go ahead and teach GCC to use the arm UBFX instruction for those cases. It DOES use it for actual bitfields. shift + mask = 2-3 instructions (immediate load may be needed). UBFX is one.
- ncmncm 5y agoThe more complicated the instruction is, the less likely it was implemented to spec on all the various products and mask steppings you might execute on ... and the less likely its published definition exactly matches C or C++ Standard and platform C ABI specs. And, the less likely that ABI spec nails down all the details. Compiler implementors don't like to guess, but don't get a choice. If the instruction provided doesn't match the Standard, which do they implement? Both choices are wrong.