I’m not really familiar with low-level (hardware-close) specifics (forgot much).
My app needs to perform millions (or even more) bit manipulation operations in very short time periods, so performance matters.
I need to check if a certain section (consisting of 4, 5 or 6 bits) of an int value is equal to a specified value.
I can solve this either by using an int as a complete mask; or by using bit shift(s) (to get rid of the disturbing sections) and then doing a direct compare (==). Do these have equal performance? Which is faster?
Generally speaking ((a & b )== c) ought to be very fast, and faster than the same operation
with an extra shift. ((a>>n)&b)==c)
It’s likely that other optimization techniques, such as loop unrollong, will be a lot more effective than trying to guess what shift and mask operations are the fastest.
If you really care about performance at that level, the answer is to benchmark all the likely variations in the actual deployment environment.