Skip to content

Commit b7d238f

Browse files
committed
BasicAA: set Offset for PartialAlias + scalable
1 parent f88eba4 commit b7d238f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,15 @@ AliasResult BasicAAResult::aliasGEP(
12211221
if (!Overflow && Off.uge(UpperRange))
12221222
return AliasResult::NoAlias;
12231223
APInt LowerRange = CR.getUnsignedMin().umul_ov(LSizeMin, Overflow);
1224-
if (!Overflow && Off.ult(LowerRange))
1225-
return AliasResult::PartialAlias;
1224+
if (!Overflow && Off.ult(LowerRange)) {
1225+
AliasResult AR = AliasResult::PartialAlias;
1226+
if (VRightSize.hasValue() && !VRightSize.isScalable() &&
1227+
Off.ule(INT32_MAX) && (Off + VRightSize.getValue()).ule(LSizeMin)) {
1228+
AR.setOffset(-Off.getSExtValue());
1229+
AR.swap(Swapped);
1230+
}
1231+
return AR;
1232+
}
12261233
}
12271234

12281235
// VScale Alias Analysis - Given one scalable offset between accesses and a

llvm/test/Analysis/BasicAA/vscale.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ define void @gep_alloca_const_offset_2() {
3232
}
3333

3434
; CHECK-LABEL: gep_alloca_const_offset_3
35-
; CHECK-DAG: MustAlias: <vscale x 4 x i32>* %alloc, <vscale x 4 x i32>* %gep1
36-
; CHECK-DAG: PartialAlias: <vscale x 4 x i32>* %alloc, i32* %gep2
37-
; CHECK-DAG: PartialAlias: <vscale x 4 x i32>* %gep1, i32* %gep2
35+
; CHECK-DAG: MustAlias: <vscale x 4 x i32>* %alloc, <vscale x 4 x i32>* %gep1
36+
; CHECK-DAG: PartialAlias (off 4): <vscale x 4 x i32>* %alloc, i32* %gep2
37+
; CHECK-DAG: PartialAlias (off 4): <vscale x 4 x i32>* %gep1, i32* %gep2
3838
define void @gep_alloca_const_offset_3() {
3939
%alloc = alloca <vscale x 4 x i32>
4040
%gep1 = getelementptr <vscale x 4 x i32>, ptr %alloc, i64 0

0 commit comments

Comments
 (0)