ARM's barrel shifter tricks

10 points by fanf


fanf

On 32 bit ARM the barrel shifter was used for immediate operands in arithmetic instructions, for address calculations in load and store instructions, as well as acting on the second operand of arithmetic instructions as outlined in the article. Back then it was still fairly common for CPUs to have multi-cycle shift instructions, so ARM was unusual in having a fast shifter and making it a central feature of most instructions. It used a fairly large proportion of the chip area. The shifter meant that it usually took only one ARM instruction to code common idioms for avoiding multiply instructions, in the years before fast multiplies became ubiquitous and optimizing compilers started rewriting the idioms for us.

Thumb and ARM64 are not such uniform instruction sets and don’t treat shifting as a big feature.