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

[Hexagon] Avoid repeated map lookups (NFC) #126185

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 7, 2025

@llvm/pr-subscribers-backend-hexagon

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h (+4-4)
diff --git a/llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h b/llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h
index cb4a7a8c393fcd4..c5df02fa3b89cb4 100644
--- a/llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h
+++ b/llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h
@@ -70,12 +70,12 @@ class HexagonMachineFunctionInfo : public MachineFunctionInfo {
     PacketInfo[MI] |= Hexagon::EndPacket;
   }
   bool isStartPacket(const MachineInstr* MI) const {
-    return (PacketInfo.count(MI) &&
-            (PacketInfo.find(MI)->second & Hexagon::StartPacket));
+    auto It = PacketInfo.find(MI);
+    return It != PacketInfo.end() && (It->second & Hexagon::StartPacket);
   }
   bool isEndPacket(const MachineInstr* MI) const {
-    return (PacketInfo.count(MI) &&
-            (PacketInfo.find(MI)->second & Hexagon::EndPacket));
+    auto It = PacketInfo.find(MI);
+    return It != PacketInfo.end() && (It->second & Hexagon::EndPacket);
   }
   void setHasClobberLR(bool v) { HasClobberLR = v;  }
   bool hasClobberLR() const { return HasClobberLR; }

@kazutakahirata kazutakahirata merged commit 46f5662 into llvm:main Feb 7, 2025
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_Hexagon branch February 7, 2025 15:58
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 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.

3 participants