Skip to content

Commit d03b36e

Browse files
committed
[Analysis] Add Scalable field in MemoryLocation.h
This is the first of a series of patch to improve Alias Analysis on Scalable quantities. Keep Scalable information from TypeSize which will be used in Alias Analysis.
1 parent 65c6e68 commit d03b36e

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

llvm/include/llvm/Analysis/MemoryLocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class LocationSize {
159159
return beforeOrAfterPointer();
160160
if (Value == AfterPointer || Other.Value == AfterPointer)
161161
return afterPointer();
162-
if (isScalable() != Other.isScalable())
162+
if (isScalable() || Other.isScalable())
163163
return afterPointer();
164164

165165
return upperBound(std::max(getValue(), Other.getValue()));

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,8 @@ static int64_t getKnownNonNullAndDerefBytesForUse(
25312531
}
25322532

25332533
std::optional<MemoryLocation> Loc = MemoryLocation::getOrNone(I);
2534-
if (!Loc || Loc->Ptr != UseV || !Loc->Size.isPrecise() || I->isVolatile())
2534+
if (!Loc || Loc->Ptr != UseV || !Loc->Size.isPrecise() ||
2535+
Loc->Size.isScalable() || I->isVolatile())
25352536
return 0;
25362537

25372538
int64_t Offset;

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,10 @@ struct DSEState {
984984
const bool AnyScalable =
985985
DeadSize.isScalable() || KillingLocSize.isScalable();
986986

987+
// TODO: Remove AnyScalable constraint once alias analysis fully support
988+
// scalable quantities
989+
if (AnyScalable)
990+
return OW_Unknown;
987991
// Query the alias information
988992
AliasResult AAR = BatchAA.alias(KillingLoc, DeadLoc);
989993

llvm/test/Transforms/LICM/memloc-vscale.ll renamed to llvm/test/Analysis/AliasSet/memloc-vscale.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ define void @ss(ptr %p) {
2525
ret void
2626
}
2727

28+
; CHECK-LABEL: Alias sets for function 'ss2':
29+
; CHECK: AliasSet[{{.*}}, 1] must alias, Mod Pointers: (ptr %p, unknown after)
30+
define void @ss2(ptr %p) {
31+
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2
32+
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2
33+
store <vscale x 4 x i64> zeroinitializer, ptr %p, align 2
34+
ret void
35+
}
2836
; CHECK-LABEL: Alias sets for function 'son':
2937
; CHECK: AliasSet[{{.*}}, 2] may alias, Mod Pointers: (ptr %g, LocationSize::precise(vscale x 16)), (ptr %p, LocationSize::precise(8))
3038
define void @son(ptr %p) {

0 commit comments

Comments
 (0)