aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2024-02-12 11:27:49 +0000
committerGitHub <noreply@github.com>2024-02-12 11:27:49 +0000
commit5e6b4be5cbddbc7538cdae0f0889b116e386fcca (patch)
treed2af43f6289d64faf9d9095fab012e9c9f32fbe3 /llvm/lib/Analysis/BasicAliasAnalysis.cpp
parent0c634537148f594203fbe946822cc38deca20ae3 (diff)
downloadllvm-5e6b4be5cbddbc7538cdae0f0889b116e386fcca.zip
llvm-5e6b4be5cbddbc7538cdae0f0889b116e386fcca.tar.gz
llvm-5e6b4be5cbddbc7538cdae0f0889b116e386fcca.tar.bz2
[BasicAA] Treat different VScale intrinsics as the same value. (#81152)
The IR may contain multiple llvm.vscale intrinsics that have not been CSEd. This patch ensures that multiple vscales can be treated the same, either in the decomposition of geps and when we subtract one decomposition from another.
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 2ea2917..8dfc4b2 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -188,6 +188,12 @@ static bool isObjectSize(const Value *V, TypeSize Size, const DataLayout &DL,
return ObjectSize && *ObjectSize == Size;
}
+/// Return true if both V1 and V2 are VScale
+static bool areBothVScale(const Value *V1, const Value *V2) {
+ return PatternMatch::match(V1, PatternMatch::m_VScale()) &&
+ PatternMatch::match(V2, PatternMatch::m_VScale());
+}
+
//===----------------------------------------------------------------------===//
// CaptureInfo implementations
//===----------------------------------------------------------------------===//
@@ -679,7 +685,8 @@ BasicAAResult::DecomposeGEPExpression(const Value *V, const DataLayout &DL,
// A[x][x] -> x*16 + x*4 -> x*20
// This also ensures that 'x' only appears in the index list once.
for (unsigned i = 0, e = Decomposed.VarIndices.size(); i != e; ++i) {
- if (Decomposed.VarIndices[i].Val.V == LE.Val.V &&
+ if ((Decomposed.VarIndices[i].Val.V == LE.Val.V ||
+ areBothVScale(Decomposed.VarIndices[i].Val.V, LE.Val.V)) &&
Decomposed.VarIndices[i].Val.hasSameCastsAs(LE.Val)) {
Scale += Decomposed.VarIndices[i].Scale;
LE.IsNSW = false; // We cannot guarantee nsw for the merge.
@@ -1792,7 +1799,8 @@ void BasicAAResult::subtractDecomposedGEPs(DecomposedGEP &DestGEP,
bool Found = false;
for (auto I : enumerate(DestGEP.VarIndices)) {
VariableGEPIndex &Dest = I.value();
- if (!isValueEqualInPotentialCycles(Dest.Val.V, Src.Val.V, AAQI) ||
+ if ((!isValueEqualInPotentialCycles(Dest.Val.V, Src.Val.V, AAQI) &&
+ !areBothVScale(Dest.Val.V, Src.Val.V)) ||
!Dest.Val.hasSameCastsAs(Src.Val))
continue;