[llvm] DynamicAPInt: optimize size of structure (PR #97831)
Arjun P via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 6 03:24:43 PDT 2024
================
@@ -35,21 +35,23 @@ namespace llvm {
/// We always_inline all operations; removing these results in a 1.5x
/// performance slowdown.
///
-/// When HoldsLarge is true, a SlowMPInt is held in the union. If it is false,
-/// the int64_t is held. Using std::variant instead would lead to significantly
-/// worse performance.
+/// When isLarge returns true, a SlowMPInt is held in the union. If isSmall
+/// returns true, the int64_t is held. We don't have a separate field for
+/// indicating this, and instead "steal" memory from ValLarge when it is not in
+/// use because we know that the memory layout of APInt is such that BitWidth
+/// doesn't overlap with ValSmall (see static_assert_layout). Using std::variant
+/// instead would lead to significantly worse performance.
----------------
Superty wrote:
Reminder to update the comment here if you move the static_assert
https://github.com/llvm/llvm-project/pull/97831
More information about the llvm-commits
mailing list