From @mmalex :
"
i cant believe i never realised before that to make a bitmask with set bits in [x0, x1), you can just do `mask = (1u<<x1)-(1u<<x0);` (obviously be sure that 0<=x0<=x1<32). ive used the degenerate case with x0==0 a billion times, but never thought to extend it. doh.
"