Skip to content

[GlobalISel] Avoid repeated hash lookups (NFC) #128461

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 24, 2025

@llvm/pr-subscribers-llvm-globalisel

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp (+4-6)
diff --git a/llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp b/llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp
index f338f66997657..9841c8ae1ffb2 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp
@@ -305,17 +305,15 @@ LegacyLegalizerInfo::findScalarLegalAction(const InstrAspect &Aspect) const {
   if (Aspect.Opcode < FirstOp || Aspect.Opcode > LastOp)
     return {NotFound, LLT()};
   const unsigned OpcodeIdx = getOpcodeIdxForOpcode(Aspect.Opcode);
+  ArrayRef<SizeAndActionsVec> Actions;
   if (Aspect.Type.isPointer()) {
     auto &PA = AddrSpace2PointerActions[OpcodeIdx];
     if (PA.find(Aspect.Type.getAddressSpace()) == PA.end())
       return {NotFound, LLT()};
+    Actions = PA.find(Aspect.Type.getAddressSpace())->second;
+  } else {
+    Actions = ScalarActions[OpcodeIdx];
   }
-  const SmallVector<SizeAndActionsVec, 1> &Actions =
-      Aspect.Type.isPointer()
-          ? AddrSpace2PointerActions[OpcodeIdx]
-                .find(Aspect.Type.getAddressSpace())
-                ->second
-          : ScalarActions[OpcodeIdx];
   if (Aspect.Idx >= Actions.size())
     return {NotFound, LLT()};
   const SizeAndActionsVec &Vec = Actions[Aspect.Idx];

@kazutakahirata kazutakahirata merged commit 71b7b1f into llvm:main Feb 24, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_GlobalISel branch February 24, 2025 07:43
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