[llvm] [llvm] Use std::tie to Implment operator< (NFC) (PR #139391)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat May 10 09:53:56 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/139391
None
>From a1d19690617471dc277173b6a8177954a0f1b0e0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 10 May 2025 09:21:24 -0700
Subject: [PATCH] [llvm] Use std::tie to Implment operator< (NFC)
---
llvm/include/llvm/Support/InstructionCost.h | 5 ++---
llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp | 6 +-----
2 files changed, 3 insertions(+), 8 deletions(-)
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