Skip to content

Commit cac4c14

Browse files
committed
[LAA] Replace std::tuple with struct (NFCI).
As suggested in #88039, replace the tuple with a struct, to make it easier to extend.
1 parent 0d17e1f commit cac4c14

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,14 +1917,30 @@ isLoopVariantIndirectAddress(ArrayRef<const Value *> UnderlyingObjects,
19171917
});
19181918
}
19191919

1920-
// Get the dependence distance, stride, type size in whether i is a write for
1920+
namespace {
1921+
struct DepDistanceStrideAndSizeInfo {
1922+
const SCEV *Dist;
1923+
uint64_t Stride;
1924+
uint64_t TypeByteSize;
1925+
bool AIsWrite;
1926+
bool BIsWrite;
1927+
1928+
DepDistanceStrideAndSizeInfo(const SCEV *Dist, uint64_t Stride,
1929+
uint64_t TypeByteSize, bool AIsWrite,
1930+
bool BIsWrite)
1931+
: Dist(Dist), Stride(Stride), TypeByteSize(TypeByteSize),
1932+
AIsWrite(AIsWrite), BIsWrite(BIsWrite) {}
1933+
};
1934+
} // namespace
1935+
1936+
// Get the dependence distance, stride, type size and whether it is a write for
19211937
// the dependence between A and B. Returns a DepType, if we can prove there's
19221938
// no dependence or the analysis fails. Outlined to lambda to limit he scope
19231939
// of various temporary variables, like A/BPtr, StrideA/BPtr and others.
19241940
// Returns either the dependence result, if it could already be determined, or a
1925-
// tuple with (Distance, Stride, TypeSize, AIsWrite, BIsWrite).
1941+
// struct containing (Distance, Stride, TypeSize, AIsWrite, BIsWrite).
19261942
static std::variant<MemoryDepChecker::Dependence::DepType,
1927-
std::tuple<const SCEV *, uint64_t, uint64_t, bool, bool>>
1943+
DepDistanceStrideAndSizeInfo>
19281944
getDependenceDistanceStrideAndSize(
19291945
const AccessAnalysis::MemAccessInfo &A, Instruction *AInst,
19301946
const AccessAnalysis::MemAccessInfo &B, Instruction *BInst,
@@ -1993,7 +2009,8 @@ getDependenceDistanceStrideAndSize(
19932009
if (!HasSameSize)
19942010
TypeByteSize = 0;
19952011
uint64_t Stride = std::abs(StrideAPtr);
1996-
return std::make_tuple(Dist, Stride, TypeByteSize, AIsWrite, BIsWrite);
2012+
return DepDistanceStrideAndSizeInfo(Dist, Stride, TypeByteSize, AIsWrite,
2013+
BIsWrite);
19972014
}
19982015

19992016
MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
@@ -2012,7 +2029,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
20122029
return std::get<Dependence::DepType>(Res);
20132030

20142031
const auto &[Dist, Stride, TypeByteSize, AIsWrite, BIsWrite] =
2015-
std::get<std::tuple<const SCEV *, uint64_t, uint64_t, bool, bool>>(Res);
2032+
std::get<DepDistanceStrideAndSizeInfo>(Res);
20162033
bool HasSameSize = TypeByteSize > 0;
20172034

20182035
ScalarEvolution &SE = *PSE.getSE();

0 commit comments

Comments
 (0)