From 1d8a4901166c89d429e4fcaaefdb8b858d6a7c2e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 5 Feb 2025 09:53:33 -0800 Subject: [PATCH 1/2] [SystemZ] Avoid repeated hash lookups (NFC) --- llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp index 1fb31c26e20d3..a1e02c0c32b61 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -6173,8 +6173,9 @@ SystemZTargetLowering::buildVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT, for (unsigned I = 0; I < NumElements; ++I) if (isVectorElementLoad(Elems[I])) { SDNode *Ld = Elems[I].getNode(); - UseCounts[Ld]++; - if (LoadMaxUses == nullptr || UseCounts[LoadMaxUses] < UseCounts[Ld]) + auto &Count = UseCounts[Ld]; + ++Count; + if (LoadMaxUses == nullptr || UseCounts[LoadMaxUses] < Count) LoadMaxUses = Ld; } if (LoadMaxUses != nullptr) { From 8eae71123c8aae0b7a6dcc63e0b56652d566434d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 6 Feb 2025 10:34:12 -0800 Subject: [PATCH 2/2] Update llvm/lib/Target/SystemZ/SystemZISelLowering.cpp Co-authored-by: Nikita Popov --- llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp index a1e02c0c32b61..9ffd4190b34bb 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -6173,8 +6173,7 @@ SystemZTargetLowering::buildVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT, for (unsigned I = 0; I < NumElements; ++I) if (isVectorElementLoad(Elems[I])) { SDNode *Ld = Elems[I].getNode(); - auto &Count = UseCounts[Ld]; - ++Count; + unsigned Count = ++UseCounts[Ld]; if (LoadMaxUses == nullptr || UseCounts[LoadMaxUses] < Count) LoadMaxUses = Ld; }