Often you want a bit-mask with the first N bits or the last N bits set to 1. This is surprisingly confusing to get right, in part because X << (8*sizeof(X)) is undefined, so trying to produce a mask of all 1s won't work, and also in part because the branch-free implementation is not obvious.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
llvm/trunk/include/llvm/Support/MathExtras.h | ||
---|---|---|
207 | Be aware that this can lead to compiler warnings, at least in MSVC, if T is an unsigned type: C4146: unary minus operator applied to unsigned type, result still unsigned Depending on the specific details, this can be a level 2 or level 3 warning. I'm surprised the tests aren't triggering it. We must disable this warning somewhere. |
Be aware that this can lead to compiler warnings, at least in MSVC, if T is an unsigned type:
C4146: unary minus operator applied to unsigned type, result still unsigned
Depending on the specific details, this can be a level 2 or level 3 warning. I'm surprised the tests aren't triggering it. We must disable this warning somewhere.