[llvm] [llvm] Use std::tie to implement comparison functors (NFC) (PR #141353)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat May 24 08:24:18 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/141353
None
>From e7a1cd2272eb6f5f4065c33cf2e8cc77069ebaea Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 23 May 2025 23:25:32 -0700
Subject: [PATCH] [llvm] Use std::tie to implement comparison functors (NFC)
---
llvm/lib/Transforms/IPO/SampleProfile.cpp | 4 +---
llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp | 6 +-----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 616eeae3b1fec..000b3ccbb3cbc 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -897,9 +897,7 @@ updateIDTMetaData(Instruction &Inst,
llvm::sort(NewCallTargets,
[](const InstrProfValueData &L, const InstrProfValueData &R) {
- if (L.Count != R.Count)
- return L.Count > R.Count;
- return L.Value > R.Value;
+ return std::tie(L.Count, L.Value) > std::tie(R.Count, R.Value);
});
uint32_t MaxMDCount =
diff --git a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
index 0690c21220f89..d6dfb65bf82e6 100644
--- a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
@@ -69,11 +69,7 @@ getNonRedundantWriteProcRes(const MCSchedClassDesc &SCDesc,
[](const ResourceMaskAndEntry &A, const ResourceMaskAndEntry &B) {
unsigned popcntA = popcount(A.first);
unsigned popcntB = popcount(B.first);
- if (popcntA < popcntB)
- return true;
- if (popcntA > popcntB)
- return false;
- return A.first < B.first;
+ return std::tie(popcntA, A.first) < std::tie(popcntB, B.first);
});
SmallVector<float, 32> ProcResUnitUsage(NumProcRes);
More information about the llvm-commits
mailing list