[llvm] 15c8ba4 - Revert "[Support] Refactor getN1Bits so it does not work around any g++ bug (#78933)"

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun May 26 23:38:36 PDT 2024


Author: Nikita Popov
Date: 2024-05-27T08:38:23+02:00
New Revision: 15c8ba4c3b92871278ccc385a696c26c4747711d

URL: https://github.com/llvm/llvm-project/commit/15c8ba4c3b92871278ccc385a696c26c4747711d
DIFF: https://github.com/llvm/llvm-project/commit/15c8ba4c3b92871278ccc385a696c26c4747711d.diff

LOG: Revert "[Support] Refactor getN1Bits so it does not work around any g++ bug (#78933)"

This reverts commit bb02bf78946a1833ea081a763f69b4f0304dd276.

PR merged without review.

Added: 
    

Modified: 
    llvm/include/llvm/Support/Discriminator.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Discriminator.h b/llvm/include/llvm/Support/Discriminator.h
index c0912bead389c..fa78cf3045de3 100644
--- a/llvm/include/llvm/Support/Discriminator.h
+++ b/llvm/include/llvm/Support/Discriminator.h
@@ -121,9 +121,12 @@ static inline unsigned getBaseFSBitEnd() {
 }
 
 // Set bits in range of [0 .. n] to 1. Used in FS Discriminators.
-static inline unsigned getN1Bits(unsigned N) {
+static inline unsigned getN1Bits(int N) {
+  // Work around the g++ bug that folding "(1U << (N + 1)) - 1" to 0.
+  if (N == 31)
+    return 0xFFFFFFFF;
   assert((N < 32) && "N is invalid");
-  return 0xFFFFFFFF >> (31 - N);
+  return (1U << (N + 1)) - 1;
 }
 
 } // namespace llvm


        


More information about the llvm-commits mailing list