Skip to content
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

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

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 12, 2025

@llvm/pr-subscribers-backend-x86

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Target/X86/X86DomainReassignment.cpp (+2-3)
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

@hstk30-hw hstk30-hw merged commit 7350978 into llvm:main Feb 12, 2025
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_X86 branch February 12, 2025 16:05
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
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.

4 participants