[llvm] cac4c14 - [LAA] Replace std::tuple with struct (NFCI).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 02:29:05 PDT 2024
Author: Florian Hahn
Date: 2024-04-10T10:28:43+01:00
New Revision: cac4c14ecfcb892201ae8f4b1559909cc22082d0
URL: https://github.com/llvm/llvm-project/commit/cac4c14ecfcb892201ae8f4b1559909cc22082d0
DIFF: https://github.com/llvm/llvm-project/commit/cac4c14ecfcb892201ae8f4b1559909cc22082d0.diff
LOG: [LAA] Replace std::tuple with struct (NFCI).
As suggested in https://github.com/llvm/llvm-project/pull/88039, replace
the tuple with a struct, to make it easier to extend.
Added:
Modified:
llvm/lib/Analysis/LoopAccessAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index c25eede96a1859..3bfc9700a14559 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1917,14 +1917,30 @@ isLoopVariantIndirectAddress(ArrayRef<const Value *> UnderlyingObjects,
});
}
-// Get the dependence distance, stride, type size in whether i is a write for
+namespace {
+struct DepDistanceStrideAndSizeInfo {
+ const SCEV *Dist;
+ uint64_t Stride;
+ uint64_t TypeByteSize;
+ bool AIsWrite;
+ bool BIsWrite;
+
+ DepDistanceStrideAndSizeInfo(const SCEV *Dist, uint64_t Stride,
+ uint64_t TypeByteSize, bool AIsWrite,
+ bool BIsWrite)
+ : Dist(Dist), Stride(Stride), TypeByteSize(TypeByteSize),
+ AIsWrite(AIsWrite), BIsWrite(BIsWrite) {}
+};
+} // namespace
+
+// Get the dependence distance, stride, type size and whether it is a write for
// the dependence between A and B. Returns a DepType, if we can prove there's
// no dependence or the analysis fails. Outlined to lambda to limit he scope
// of various temporary variables, like A/BPtr, StrideA/BPtr and others.
// Returns either the dependence result, if it could already be determined, or a
-// tuple with (Distance, Stride, TypeSize, AIsWrite, BIsWrite).
+// struct containing (Distance, Stride, TypeSize, AIsWrite, BIsWrite).
static std::variant<MemoryDepChecker::Dependence::DepType,
- std::tuple<const SCEV *, uint64_t, uint64_t, bool, bool>>
+ DepDistanceStrideAndSizeInfo>
getDependenceDistanceStrideAndSize(
const AccessAnalysis::MemAccessInfo &A, Instruction *AInst,
const AccessAnalysis::MemAccessInfo &B, Instruction *BInst,
@@ -1993,7 +2009,8 @@ getDependenceDistanceStrideAndSize(
if (!HasSameSize)
TypeByteSize = 0;
uint64_t Stride = std::abs(StrideAPtr);
- return std::make_tuple(Dist, Stride, TypeByteSize, AIsWrite, BIsWrite);
+ return DepDistanceStrideAndSizeInfo(Dist, Stride, TypeByteSize, AIsWrite,
+ BIsWrite);
}
MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
@@ -2012,7 +2029,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
return std::get<Dependence::DepType>(Res);
const auto &[Dist, Stride, TypeByteSize, AIsWrite, BIsWrite] =
- std::get<std::tuple<const SCEV *, uint64_t, uint64_t, bool, bool>>(Res);
+ std::get<DepDistanceStrideAndSizeInfo>(Res);
bool HasSameSize = TypeByteSize > 0;
ScalarEvolution &SE = *PSE.getSE();
More information about the llvm-commits
mailing list