-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[JumpThreading] Use SmallPtrSet (NFC) #95674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JumpThreading] Use SmallPtrSet (NFC) #95674
Conversation
The use of SmallDenseSet here saves 0.58% of heap allocations during the compilation of a large preprocessed file, namely X86ISelLowering.cpp, for the X86 target.
@llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesThe use of SmallDenseSet here saves 0.58% of heap allocations during Full diff: https://github.com/llvm/llvm-project/pull/95674.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
index 65d43775bdc1d..1bf79fdcb697e 100644
--- a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
+++ b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
@@ -130,13 +130,13 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
bool computeValueKnownInPredecessorsImpl(
Value *V, BasicBlock *BB, jumpthreading::PredValueInfo &Result,
jumpthreading::ConstantPreference Preference,
- DenseSet<Value *> &RecursionSet, Instruction *CxtI = nullptr);
+ SmallDenseSet<Value *> &RecursionSet, Instruction *CxtI = nullptr);
bool
computeValueKnownInPredecessors(Value *V, BasicBlock *BB,
jumpthreading::PredValueInfo &Result,
jumpthreading::ConstantPreference Preference,
Instruction *CxtI = nullptr) {
- DenseSet<Value *> RecursionSet;
+ SmallDenseSet<Value *> RecursionSet;
return computeValueKnownInPredecessorsImpl(V, BB, Result, Preference,
RecursionSet, CxtI);
}
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index b9583836aea06..a4a04d5d16d4a 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -558,7 +558,7 @@ static Constant *getKnownConstant(Value *Val, ConstantPreference Preference) {
/// This returns true if there were any known values.
bool JumpThreadingPass::computeValueKnownInPredecessorsImpl(
Value *V, BasicBlock *BB, PredValueInfo &Result,
- ConstantPreference Preference, DenseSet<Value *> &RecursionSet,
+ ConstantPreference Preference, SmallDenseSet<Value *> &RecursionSet,
Instruction *CxtI) {
const DataLayout &DL = BB->getModule()->getDataLayout();
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it would be even better to switch this to SmallPtrSet.
Thanks! |
The use of SmallPtrSet here saves 0.66% of heap allocations during
the compilation of a large preprocessed file, namely
X86ISelLowering.cpp, for the X86 target.