[llvm] 6c31984 - [llvm] Use std::tie to implement operator< (NFC) (#139391)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 11:38:27 PDT 2025
Author: Kazu Hirata
Date: 2025-05-11T11:38:23-07:00
New Revision: 6c31984a4cf2a2aac791174ccee2a7c6d52c5a3b
URL: https://github.com/llvm/llvm-project/commit/6c31984a4cf2a2aac791174ccee2a7c6d52c5a3b
DIFF: https://github.com/llvm/llvm-project/commit/6c31984a4cf2a2aac791174ccee2a7c6d52c5a3b.diff
LOG: [llvm] Use std::tie to implement operator< (NFC) (#139391)
Added:
Modified:
llvm/include/llvm/Support/InstructionCost.h
llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/InstructionCost.h b/llvm/include/llvm/Support/InstructionCost.h
index d5f7457e04748..8e8aa6cfd717b 100644
--- a/llvm/include/llvm/Support/InstructionCost.h
+++ b/llvm/include/llvm/Support/InstructionCost.h
@@ -20,6 +20,7 @@
#include "llvm/Support/MathExtras.h"
#include <limits>
+#include <tuple>
namespace llvm {
@@ -191,9 +192,7 @@ class InstructionCost {
/// the states are valid and users can test for validity of the cost
/// explicitly.
bool operator<(const InstructionCost &RHS) const {
- if (State != RHS.State)
- return State < RHS.State;
- return Value < RHS.Value;
+ return std::tie(State, Value) < std::tie(RHS.State, RHS.Value);
}
bool operator==(const InstructionCost &RHS) const {
diff --git a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
index bc51b293b5dda..f38e7b879e5f0 100644
--- a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
@@ -107,11 +107,7 @@ namespace {
return !operator==(R);
}
bool operator<(const OffsetRange &R) const {
- if (Min != R.Min)
- return Min < R.Min;
- if (Max != R.Max)
- return Max < R.Max;
- return Align < R.Align;
+ return std::tie(Min, Max, Align) < std::tie(R.Min, R.Max, R.Align);
}
static OffsetRange zero() { return {0, 0, 1}; }
};
More information about the llvm-commits
mailing list