[llvm] [NFC][GISel] Pass `APInt` by const reference (PR #164556)
Abhishek Kaushik via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 21 23:31:28 PDT 2025
https://github.com/abhishek-kaushik22 created https://github.com/llvm/llvm-project/pull/164556
Change function signature to avoid copying the argument at call site.
>From ae8db3457225da53180391b9c689b6106ef113b3 Mon Sep 17 00:00:00 2001
From: Abhishek Kaushik <abhishek.kaushik at intel.com>
Date: Wed, 22 Oct 2025 12:00:37 +0530
Subject: [PATCH] [NFC][GISel] Pass `APInt` by const reference
Change function signature to avoid copying the argument at call site.
---
.../llvm/CodeGen/GlobalISel/MIPatternMatch.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
index b7ccfbb27e51c..8db99ba4ed883 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
@@ -210,8 +210,8 @@ struct SpecificConstantMatch {
};
/// Matches a constant equal to \p RequestedValue.
-inline SpecificConstantMatch m_SpecificICst(APInt RequestedValue) {
- return SpecificConstantMatch(std::move(RequestedValue));
+inline SpecificConstantMatch m_SpecificICst(const APInt &RequestedValue) {
+ return SpecificConstantMatch(RequestedValue);
}
inline SpecificConstantMatch m_SpecificICst(int64_t RequestedValue) {
@@ -221,7 +221,7 @@ inline SpecificConstantMatch m_SpecificICst(int64_t RequestedValue) {
/// Matcher for a specific constant splat.
struct SpecificConstantSplatMatch {
APInt RequestedVal;
- SpecificConstantSplatMatch(const APInt RequestedVal)
+ SpecificConstantSplatMatch(const APInt &RequestedVal)
: RequestedVal(RequestedVal) {}
bool match(const MachineRegisterInfo &MRI, Register Reg) {
return isBuildVectorConstantSplat(Reg, MRI, RequestedVal,
@@ -230,8 +230,9 @@ struct SpecificConstantSplatMatch {
};
/// Matches a constant splat of \p RequestedValue.
-inline SpecificConstantSplatMatch m_SpecificICstSplat(APInt RequestedValue) {
- return SpecificConstantSplatMatch(std::move(RequestedValue));
+inline SpecificConstantSplatMatch
+m_SpecificICstSplat(const APInt &RequestedValue) {
+ return SpecificConstantSplatMatch(RequestedValue);
}
inline SpecificConstantSplatMatch m_SpecificICstSplat(int64_t RequestedValue) {
@@ -242,7 +243,7 @@ inline SpecificConstantSplatMatch m_SpecificICstSplat(int64_t RequestedValue) {
/// Matcher for a specific constant or constant splat.
struct SpecificConstantOrSplatMatch {
APInt RequestedVal;
- SpecificConstantOrSplatMatch(const APInt RequestedVal)
+ SpecificConstantOrSplatMatch(const APInt &RequestedVal)
: RequestedVal(RequestedVal) {}
bool match(const MachineRegisterInfo &MRI, Register Reg) {
APInt MatchedVal;
@@ -263,8 +264,8 @@ struct SpecificConstantOrSplatMatch {
/// Matches a \p RequestedValue constant or a constant splat of \p
/// RequestedValue.
inline SpecificConstantOrSplatMatch
-m_SpecificICstOrSplat(APInt RequestedValue) {
- return SpecificConstantOrSplatMatch(std::move(RequestedValue));
+m_SpecificICstOrSplat(const APInt &RequestedValue) {
+ return SpecificConstantOrSplatMatch(RequestedValue);
}
inline SpecificConstantOrSplatMatch
More information about the llvm-commits
mailing list