[llvm] [X86] Avoid repeated hash lookups (NFC) (PR #126006)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 5 21:17:33 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/126006.diff
1 Files Affected:
- (modified) llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp (+4-7)
``````````diff
diff --git a/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp b/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
index 1919923f41bb20..fe9bacb6856a6a 100644
--- a/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
+++ b/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
@@ -625,13 +625,10 @@ static bool isBlockingStore(int64_t LoadDispImm, unsigned LoadSize,
static void
updateBlockingStoresDispSizeMap(DisplacementSizeMap &BlockingStoresDispSizeMap,
int64_t DispImm, unsigned Size) {
- if (BlockingStoresDispSizeMap.count(DispImm)) {
- // Choose the smallest blocking store starting at this displacement.
- if (BlockingStoresDispSizeMap[DispImm] > Size)
- BlockingStoresDispSizeMap[DispImm] = Size;
-
- } else
- BlockingStoresDispSizeMap[DispImm] = Size;
+ auto [It, Inserted] = BlockingStoresDispSizeMap.try_emplace(DispImm, Size);
+ // Choose the smallest blocking store starting at this displacement.
+ if (!Inserted && It->second > Size)
+ It->second = Size;
}
// Remove blocking stores contained in each other.
``````````
</details>
https://github.com/llvm/llvm-project/pull/126006
More information about the llvm-commits
mailing list