[llvm] 3ccda93 - [LAA] Update pointer-bounds cache to also consider access type.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 14 09:25:37 PDT 2024
Author: Florian Hahn
Date: 2024-07-14T17:24:12+01:00
New Revision: 3ccda936710d55d819c56cf4f2cf307c2d632b63
URL: https://github.com/llvm/llvm-project/commit/3ccda936710d55d819c56cf4f2cf307c2d632b63
DIFF: https://github.com/llvm/llvm-project/commit/3ccda936710d55d819c56cf4f2cf307c2d632b63.diff
LOG: [LAA] Update pointer-bounds cache to also consider access type.
The same pointer may be accessed with different types and the bound
includes the size of the accessed type to compute the end. Update the
cache to correctly disambiguate between different accessed types.
Added:
Modified:
llvm/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/test/Analysis/LoopAccessAnalysis/different-access-types-rt-checks.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index f6bb044392938..afafb74bdcb0a 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -269,7 +269,8 @@ class MemoryDepChecker {
const Loop *getInnermostLoop() const { return InnermostLoop; }
- DenseMap<const SCEV *, std::pair<const SCEV *, const SCEV *>> &
+ DenseMap<std::pair<const SCEV *, Type *>,
+ std::pair<const SCEV *, const SCEV *>> &
getPointerBounds() {
return PointerBounds;
}
@@ -334,7 +335,9 @@ class MemoryDepChecker {
/// Mapping of SCEV expressions to their expanded pointer bounds (pair of
/// start and end pointer expressions).
- DenseMap<const SCEV *, std::pair<const SCEV *, const SCEV *>> PointerBounds;
+ DenseMap<std::pair<const SCEV *, Type *>,
+ std::pair<const SCEV *, const SCEV *>>
+ PointerBounds;
/// Check whether there is a plausible dependence between the two
/// accesses.
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 018861a665c4c..91994f33f3046 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -206,12 +206,13 @@ RuntimeCheckingPtrGroup::RuntimeCheckingPtrGroup(
static std::pair<const SCEV *, const SCEV *> getStartAndEndForAccess(
const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy,
PredicatedScalarEvolution &PSE,
- DenseMap<const SCEV *, std::pair<const SCEV *, const SCEV *>>
- &PointerBounds) {
+ DenseMap<std::pair<const SCEV *, Type *>,
+ std::pair<const SCEV *, const SCEV *>> &PointerBounds) {
ScalarEvolution *SE = PSE.getSE();
auto [Iter, Ins] = PointerBounds.insert(
- {PtrExpr, {SE->getCouldNotCompute(), SE->getCouldNotCompute()}});
+ {{PtrExpr, AccessTy},
+ {SE->getCouldNotCompute(), SE->getCouldNotCompute()}});
if (!Ins)
return Iter->second;
diff --git a/llvm/test/Analysis/LoopAccessAnalysis/
diff erent-access-types-rt-checks.ll b/llvm/test/Analysis/LoopAccessAnalysis/
diff erent-access-types-rt-checks.ll
index 147119289b9ec..58844c10cdcb9 100644
--- a/llvm/test/Analysis/LoopAccessAnalysis/
diff erent-access-types-rt-checks.ll
+++ b/llvm/test/Analysis/LoopAccessAnalysis/
diff erent-access-types-rt-checks.ll
@@ -3,8 +3,6 @@
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
-; FIXME: The runtime checks for A are based on i8 accesses, but should be based
-; on i32.
define void @loads_of_same_pointer_with_
diff erent_sizes1(ptr %A, ptr %B, i64 %N) {
; CHECK-LABEL: 'loads_of_same_pointer_with_
diff erent_sizes1'
; CHECK-NEXT: loop:
@@ -22,7 +20,7 @@ define void @loads_of_same_pointer_with_
diff erent_sizes1(ptr %A, ptr %B, i64 %N)
; CHECK-NEXT: (Low: %B High: ((4 * %N) + %B))
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop>
; CHECK-NEXT: Group [[GRP2]]:
-; CHECK-NEXT: (Low: %A High: (%N + %A))
+; CHECK-NEXT: (Low: %A High: (3 + %N + %A))
; CHECK-NEXT: Member: {%A,+,1}<nuw><%loop>
; CHECK-NEXT: Member: {%A,+,1}<nuw><%loop>
; CHECK-EMPTY:
@@ -101,8 +99,6 @@ exit:
ret void
}
-; FIXME: The both runtime checks for A are based on i8 accesses, but one should
-; be based on i32.
define void @loads_of_same_pointer_with_
diff erent_sizes_retry_with_runtime_checks(ptr %A, ptr %B, i64 %N, i64 %off) {
; CHECK-LABEL: 'loads_of_same_pointer_with_
diff erent_sizes_retry_with_runtime_checks'
; CHECK-NEXT: loop:
@@ -145,7 +141,7 @@ define void @loads_of_same_pointer_with_
diff erent_sizes_retry_with_runtime_check
; CHECK-NEXT: (Low: %A High: (%N + %A))
; CHECK-NEXT: Member: {%A,+,1}<nuw><%loop>
; CHECK-NEXT: Group [[GRP8]]:
-; CHECK-NEXT: (Low: %A High: (%N + %A))
+; CHECK-NEXT: (Low: %A High: (3 + %N + %A))
; CHECK-NEXT: Member: {%A,+,1}<nuw><%loop>
; CHECK-EMPTY:
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
More information about the llvm-commits
mailing list