Skip to content

Commit 43ab5bb

Browse files
[CodeGen] Use std::tie to implement a comparison functor (NFC) (#146252)
std::tie clearly expresses the intent while slightly shortening the code.
1 parent d2d5203 commit 43ab5bb

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

llvm/lib/CodeGen/MachineScheduler.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,13 +1290,13 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceTopDown() const {
12901290
SchedModel.getWriteProcResEnd(SC)));
12911291

12921292
if (MISchedSortResourcesInTrace)
1293-
llvm::stable_sort(ResourcesIt,
1294-
[](const MCWriteProcResEntry &LHS,
1295-
const MCWriteProcResEntry &RHS) -> bool {
1296-
return LHS.AcquireAtCycle < RHS.AcquireAtCycle ||
1297-
(LHS.AcquireAtCycle == RHS.AcquireAtCycle &&
1298-
LHS.ReleaseAtCycle < RHS.ReleaseAtCycle);
1299-
});
1293+
llvm::stable_sort(
1294+
ResourcesIt,
1295+
[](const MCWriteProcResEntry &LHS,
1296+
const MCWriteProcResEntry &RHS) -> bool {
1297+
return std::tie(LHS.AcquireAtCycle, LHS.ReleaseAtCycle) <
1298+
std::tie(RHS.AcquireAtCycle, RHS.ReleaseAtCycle);
1299+
});
13001300
for (const MCWriteProcResEntry &PI : ResourcesIt) {
13011301
C = FirstCycle;
13021302
const std::string ResName =
@@ -1371,13 +1371,13 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceBottomUp() const {
13711371
SchedModel.getWriteProcResEnd(SC)));
13721372

13731373
if (MISchedSortResourcesInTrace)
1374-
llvm::stable_sort(ResourcesIt,
1375-
[](const MCWriteProcResEntry &LHS,
1376-
const MCWriteProcResEntry &RHS) -> bool {
1377-
return LHS.AcquireAtCycle < RHS.AcquireAtCycle ||
1378-
(LHS.AcquireAtCycle == RHS.AcquireAtCycle &&
1379-
LHS.ReleaseAtCycle < RHS.ReleaseAtCycle);
1380-
});
1374+
llvm::stable_sort(
1375+
ResourcesIt,
1376+
[](const MCWriteProcResEntry &LHS,
1377+
const MCWriteProcResEntry &RHS) -> bool {
1378+
return std::tie(LHS.AcquireAtCycle, LHS.ReleaseAtCycle) <
1379+
std::tie(RHS.AcquireAtCycle, RHS.ReleaseAtCycle);
1380+
});
13811381
for (const MCWriteProcResEntry &PI : ResourcesIt) {
13821382
C = FirstCycle;
13831383
const std::string ResName =

0 commit comments

Comments
 (0)