[llvm] [ADT] Simplify IntMask (NFC) (PR #158410)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 13 00:09:25 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/158410

We can do the shift in uintptr_t without going through intptr_t.


>From 11016a3d26b48acf5eebdd4f5b3d428264244dde Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 12 Sep 2025 10:02:44 -0700
Subject: [PATCH] [ADT] Simplify IntMask (NFC)

We can do the shift in uintptr_t without going through intptr_t.
---
 llvm/include/llvm/ADT/PointerIntPair.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index e48e35d476c80..75e3a58e7ca61 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -180,7 +180,7 @@ struct PointerIntPairInfo {
     IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable - IntBits,
 
     /// IntMask - This is the unshifted mask for valid bits of the int type.
-    IntMask = (uintptr_t)(((intptr_t)1 << IntBits) - 1),
+    IntMask = ((uintptr_t)1 << IntBits) - 1,
 
     // ShiftedIntMask - This is the bits for the integer shifted in place.
     ShiftedIntMask = (uintptr_t)(IntMask << IntShift)



More information about the llvm-commits mailing list