[llvm] [LAA] Get conflicts in loop-invariant addresses (PR #180945)
Raphael Moreira Zinsly via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 11 06:09:53 PST 2026
https://github.com/rzinsly created https://github.com/llvm/llvm-project/pull/180945
This is part of the work tracked in #168312.
In preparation to #165312, add the ability to gather the pairs of load and store that conflicts by accessing the same IV address.
Co-Authored-By: Felipe Magno de Almeida <felipe at expertise.dev>
>From fdea554a8d5fe753bc211c7156bc1bf4d3ce445c Mon Sep 17 00:00:00 2001
From: Raphael Moreira Zinsly <raphael.zinsly at oss.qualcomm.com>
Date: Wed, 11 Feb 2026 10:40:38 -0300
Subject: [PATCH] [LAA] Get conflicts between loop-invariant addresses
In preparation to #165312, add the ability to gather the pairs of load
and store that conflicts by accessing the same IV address.
Co-Authored-By: Felipe Magno de Almeida <felipe at expertise.dev>
---
llvm/include/llvm/Analysis/LoopAccessAnalysis.h | 9 +++++++++
llvm/lib/Analysis/LoopAccessAnalysis.cpp | 15 +++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index c85ef3e131068..3016b7e5cec36 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -775,6 +775,12 @@ class LoopAccessInfo {
return StoresToInvariantAddresses;
}
+ /// Returns conflicts between loads and stores to invariant addresses.
+ ArrayRef<std::pair<LoadInst *, StoreInst *>>
+ getInvariantAddressConflicts() const {
+ return InvariantAddressConflicts;
+ }
+
/// Used to add runtime SCEV checks. Simplifies SCEV expressions and converts
/// them to a more usable form. All SCEV expressions during the analysis
/// should be re-written (and therefore simplified) according to PSE.
@@ -853,6 +859,9 @@ class LoopAccessInfo {
/// List of stores to invariant addresses.
SmallVector<StoreInst *> StoresToInvariantAddresses;
+ /// List of conflict pair due to accessing the same loop-invariant address.
+ SmallVector<std::pair<LoadInst *, StoreInst *>> InvariantAddressConflicts;
+
/// The diagnostics report generated for the analysis. E.g. why we
/// couldn't analyze the loop.
std::unique_ptr<OptimizationRemarkAnalysis> Report;
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index eae645ab84fff..87c8ea89ff9ac 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2685,6 +2685,21 @@ bool LoopAccessInfo::analyzeLoop(AAResults *AA, const LoopInfo *LI,
}
}
+ // Gather the loop-invariant address with conflicts.
+ for (LoadInst *LD : Loads) {
+ Value *Ptr = LD->getPointerOperand();
+ if (UniformStores.contains(Ptr)) {
+ if (TheLoop->isLoopInvariant(LD->getPointerOperand())) {
+ for (StoreInst *ST : StoresToInvariantAddresses) {
+ if (ST->getPointerOperand() == Ptr) {
+ InvariantAddressConflicts.emplace_back(LD, ST);
+ break;
+ }
+ }
+ }
+ }
+ }
+
if (IsAnnotatedParallel) {
LLVM_DEBUG(
dbgs() << "LAA: A loop annotated parallel, ignore memory dependency "
More information about the llvm-commits
mailing list