[llvm] [Transforms] Avoid repeated hash looksup (NFC) (PR #107727)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 7 16:12:50 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/107727.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp (+1-3) 


``````````diff
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
index c7b88d3c48a69f..2c2400d9dd7a82 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
@@ -139,11 +139,9 @@ static bool processHeaderPhiOperands(BasicBlock *Header, BasicBlock *Latch,
   SmallPtrSet<Instruction *, 8> VisitedInstr;
 
   std::function<bool(Instruction * I)> ProcessInstr = [&](Instruction *I) {
-    if (VisitedInstr.count(I))
+    if (!VisitedInstr.insert(I).second)
       return true;
 
-    VisitedInstr.insert(I);
-
     if (AftBlocks.count(I->getParent()))
       for (auto &U : I->operands())
         if (Instruction *II = dyn_cast<Instruction>(U))

``````````

</details>


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


More information about the llvm-commits mailing list