Skip to content

Commit bb02bf7

Browse files
authored
[Support] Refactor getN1Bits so it does not work around any g++ bug (llvm#78933)
This also folds better than the previous version as well. Proof: https://alive2.llvm.org/ce/z/6uwy95
1 parent 972f297 commit bb02bf7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

llvm/include/llvm/Support/Discriminator.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,9 @@ static inline unsigned getBaseFSBitEnd() {
121121
}
122122

123123
// Set bits in range of [0 .. n] to 1. Used in FS Discriminators.
124-
static inline unsigned getN1Bits(int N) {
125-
// Work around the g++ bug that folding "(1U << (N + 1)) - 1" to 0.
126-
if (N == 31)
127-
return 0xFFFFFFFF;
124+
static inline unsigned getN1Bits(unsigned N) {
128125
assert((N < 32) && "N is invalid");
129-
return (1U << (N + 1)) - 1;
126+
return 0xFFFFFFFF >> (31 - N);
130127
}
131128

132129
} // namespace llvm

0 commit comments

Comments
 (0)