That only check that the number is pair. To check for 2^M use this instead: 
https://github.com/RAttab/lockless/blob/master/src/utils.h#L30