Skip to content

[DFAJumpThreading] Avoid repeated hash lookups (NFC) #107670

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

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp (+2-4)
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 58f06ca8b0297b..ef9c264482a640 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -502,10 +502,8 @@ struct MainSwitch {
   void addToQueue(Value *Val, BasicBlock *BB,
                   std::deque<std::pair<Value *, BasicBlock *>> &Q,
                   SmallSet<Value *, 16> &SeenValues) {
-    if (SeenValues.contains(Val))
-      return;
-    Q.push_back({Val, BB});
-    SeenValues.insert(Val);
+    if (SeenValues.insert(Val).second)
+      Q.push_back({Val, BB});
   }
 
   bool isValidSelectInst(SelectInst *SI) {

@kazutakahirata kazutakahirata merged commit 23a26e7 into llvm:main Sep 7, 2024
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_DFA branch September 7, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants