[llvm] [X86] Avoid repeated hash lookups (NFC) (PR #126857)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 21:06:47 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/lib/Target/X86/X86DomainReassignment.cpp (+2-3) 


``````````diff
diff --git a/llvm/lib/Target/X86/X86DomainReassignment.cpp b/llvm/lib/Target/X86/X86DomainReassignment.cpp
index a3547f802976b..25f81834bfa5e 100644
--- a/llvm/lib/Target/X86/X86DomainReassignment.cpp
+++ b/llvm/lib/Target/X86/X86DomainReassignment.cpp
@@ -451,8 +451,8 @@ bool X86DomainReassignment::visitRegister(Closure &C, Register Reg,
 }
 
 bool X86DomainReassignment::encloseInstr(Closure &C, MachineInstr *MI) {
-  auto I = EnclosedInstrs.find(MI);
-  if (I != EnclosedInstrs.end()) {
+  auto [I, Inserted] = EnclosedInstrs.try_emplace(MI, C.getID());
+  if (!Inserted) {
     if (I->second != C.getID()) {
       // Instruction already belongs to another closure, avoid conflicts between
       // closure and mark this closure as illegal.
@@ -462,7 +462,6 @@ bool X86DomainReassignment::encloseInstr(Closure &C, MachineInstr *MI) {
     return true;
   }
 
-  EnclosedInstrs[MI] = C.getID();
   C.addInstruction(MI);
 
   // Mark closure as illegal for reassignment to domains, if there is no

``````````

</details>


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


More information about the llvm-commits mailing list