[all-commits] [llvm/llvm-project] e429ba: [IR][ADT] Avoid isPointerIntoBucketsArray in Remov...
Kazu Hirata via All-commits
all-commits at lists.llvm.org
Fri Oct 2 13:05:03 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e429baa2a3489144b967b6c4f0f5cec1ddd199ac
https://github.com/llvm/llvm-project/commit/e429baa2a3489144b967b6c4f0f5cec1ddd199ac
Author: Kazu Hirata <kazu at google.com>
Date: 2026-10-02 (Fri, 02 Oct 2026)
Changed paths:
M llvm/include/llvm/ADT/DenseMap.h
M llvm/include/llvm/IR/ValueHandle.h
M llvm/lib/IR/LLVMContextImpl.h
M llvm/lib/IR/Value.cpp
Log Message:
-----------
[IR][ADT] Avoid isPointerIntoBucketsArray in RemoveFromUseList (NFC) (#228325)
RemoveFromUseList erases the entry from ValueHandles when removing the
sole remaining element in the doubly linked list. Without this patch,
after unlinking the tail element, it checks whether PrevPtr points into
the DenseMap bucket array:
if (Handles.isPointerIntoBucketsArray(PrevPtr)) {
Handles.erase(getValPtr());
This patch instead tags ValueHandleHead::Head with true via
PointerIntPair<ValueHandleBase *, 1, bool>, while leaving
ValueHandleBase::Next untagged. The tag bit allows RemoveFromUseList to
quickly determine whether it is removing the sole element in the list
without calling isPointerIntoBucketsArray.
Below is the breakdown of RemoveFromUseList calls and the perf stat -r10
comparison when compiling SLPVectorizer.ii with clang -O3:
Category Count %
---------------------------------------------------------
Non-tail element (Next != nullptr) 16,592,855 52.7%
Sole remaining element (erased) 8,198,144 26.0%
Tail of multi-element list (not erased) 6,714,742 21.3%
---------------------------------------------------------
Total 31,505,741 100.0%
Metric Base Test Delta
--------------------------------------------------------
instructions:u 194,745,673,762 194,513,892,029 -0.12%
cpu-cycles:u 141,184,939,025 141,042,112,760 -0.10%
time elapsed 54.9115s 54.8629s -0.09%
The instruction count decreases slightly because IsHead is readily
available from *PrevPtr. We do not need to chase
getValPtr()->getContext().pImpl or check bucket bounds when removing
the tail of a multi-element list.
With the final use of isPointerIntoBucketsArray gone, this patch removes
the following unused methods from DenseMapBase:
- isPointerIntoBucketsArray
- getPointerIntoBucketsArray
- getBucketsEnd
Assisted-by: Antigravity
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list