What is the most efficient way to zero all bits below the most significant set bit?
问题 So for the following sequence: 0001000111000 The desired result would be: 0001000000000 I am fully aware that this is achievable by finding the MSB's index with assembly BSRL (or similar bit-twiddling hack) then >> bit shifting the number by (index - 1), then << shifting back by (index - 1), but I want to know whether there is, specifically, an assembly instruction or a sequence of instructions with better performance, not a bit-twiddling hack that can do this. 回答1: There's no single