[PATCH] D58687: [TableGen] Make OpcodeMappings sort comparator deterministic NFCI
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 26 10:50:17 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354910: [TableGen] Make OpcodeMappings sort comparator deterministic NFCI (authored by anng, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D58687?vs=188410&id=188418#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58687/new/
https://reviews.llvm.org/D58687
Files:
llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
Index: llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
===================================================================
--- llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
+++ llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
@@ -368,24 +368,22 @@
[&](const OpcodeMapPair &Lhs, const OpcodeMapPair &Rhs) {
unsigned LhsIdx = Opcode2Index[Lhs.first];
unsigned RhsIdx = Opcode2Index[Rhs.first];
- std::pair<APInt, APInt> &LhsMasks = OpcodeMasks[LhsIdx];
- std::pair<APInt, APInt> &RhsMasks = OpcodeMasks[RhsIdx];
+ const std::pair<APInt, APInt> &LhsMasks = OpcodeMasks[LhsIdx];
+ const std::pair<APInt, APInt> &RhsMasks = OpcodeMasks[RhsIdx];
- if (LhsMasks.first != RhsMasks.first) {
- if (LhsMasks.first.countPopulation() <
- RhsMasks.first.countPopulation())
- return true;
- return LhsMasks.first.countLeadingZeros() >
- RhsMasks.first.countLeadingZeros();
- }
-
- if (LhsMasks.second != RhsMasks.second) {
- if (LhsMasks.second.countPopulation() <
- RhsMasks.second.countPopulation())
- return true;
- return LhsMasks.second.countLeadingZeros() >
- RhsMasks.second.countLeadingZeros();
- }
+ auto LessThan = [](const APInt &Lhs, const APInt &Rhs) {
+ unsigned LhsCountPopulation = Lhs.countPopulation();
+ unsigned RhsCountPopulation = Rhs.countPopulation();
+ return ((LhsCountPopulation < RhsCountPopulation) ||
+ ((LhsCountPopulation == RhsCountPopulation) &&
+ (Lhs.countLeadingZeros() > Rhs.countLeadingZeros())));
+ };
+
+ if (LhsMasks.first != RhsMasks.first)
+ return LessThan(LhsMasks.first, RhsMasks.first);
+
+ if (LhsMasks.second != RhsMasks.second)
+ return LessThan(LhsMasks.second, RhsMasks.second);
return LhsIdx < RhsIdx;
});
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58687.188418.patch
Type: text/x-patch
Size: 2203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190226/acb88d71/attachment.bin>
More information about the llvm-commits
mailing list