Is a logical right shift by a power of 2 faster in AVR?

后端 未结 9 1585
栀梦
栀梦 2020-12-06 19:21

I would like to know if performing a logical right shift is faster when shifting by a power of 2

For example, is

myUnsigned >> 4
9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 20:06

    If your targer processor has a bit-shift instruction (which is very likely), then it depends on the hardware-implementation of that instruction if there will be any difference between shifting a power-of-2 bits, or shifting some other number. However, it is unlikely to make a difference.

提交回复
热议问题