File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
llvm/include/llvm/Bitcode Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -338,16 +338,14 @@ class BitstreamCursor {
338
338
}
339
339
340
340
word_t Read (unsigned NumBits) {
341
- static const unsigned BitsInWord = sizeof (word_t ) * 8 ;
342
-
343
- assert (NumBits && NumBits <= BitsInWord &&
341
+ assert (NumBits && NumBits <= sizeof (word_t ) * 8 &&
344
342
" Cannot return zero or more than BitsInWord bits!" );
345
343
346
344
static const unsigned Mask = sizeof (word_t ) > 4 ? 0x3f : 0x1f ;
347
345
348
346
// If the field is fully contained by CurWord, return it quickly.
349
347
if (BitsInCurWord >= NumBits) {
350
- word_t R = CurWord & (~ word_t (0 ) >> (BitsInWord - NumBits) );
348
+ word_t R = CurWord & (( word_t (1 ) << NumBits) - 1 );
351
349
352
350
// Use a mask to avoid undefined behavior.
353
351
CurWord >>= (NumBits & Mask);
@@ -365,7 +363,7 @@ class BitstreamCursor {
365
363
if (BitsLeft > BitsInCurWord)
366
364
return 0 ;
367
365
368
- word_t R2 = CurWord & (~ word_t (0 ) >> (BitsInWord - BitsLeft) );
366
+ word_t R2 = CurWord & (( word_t (1 ) << BitsLeft) - 1 );
369
367
370
368
// Use a mask to avoid undefined behavior.
371
369
CurWord >>= (BitsLeft & Mask);
You can’t perform that action at this time.
0 commit comments