Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

Without this patch, Int and IntWord have the same value and type.
This patch removes the extraneous copy.

Without this patch, Int and IntWord have the same value and type.
This patch removes the extraneous copy.
@llvmbot
Copy link
Member

llvmbot commented Jun 19, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

Without this patch, Int and IntWord have the same value and type.
This patch removes the extraneous copy.


Full diff: https://github.com/llvm/llvm-project/pull/144937.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/PointerIntPair.h (+2-3)
diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index f73f5bcd6ce0c..9cfc65846d5bf 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -206,11 +206,10 @@ struct PointerIntPairInfo {
   }
 
   static intptr_t updateInt(intptr_t OrigValue, intptr_t Int) {
-    intptr_t IntWord = static_cast<intptr_t>(Int);
-    assert((IntWord & ~IntMask) == 0 && "Integer too large for field");
+    assert((Int & ~IntMask) == 0 && "Integer too large for field");
 
     // Preserve all bits other than the ones we are updating.
-    return (OrigValue & ~ShiftedIntMask) | IntWord << IntShift;
+    return (OrigValue & ~ShiftedIntMask) | Int << IntShift;
   }
 };
 

@kazutakahirata kazutakahirata merged commit 7349864 into llvm:main Jun 19, 2025
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250619_cast_PointerIntPair branch June 19, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants