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

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 23:48:12 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp (+2-4) 


``````````diff
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) {

``````````

</details>


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


More information about the llvm-commits mailing list