Skip to content

Commit 0079136

Browse files
authored
[BasicAA] Fix Scale check in vscale aliasing. (#81174)
This is a fix for #80818, as pointed out in #81144 it should be checking the abs of Scale. The added test changes from NoAlias to MayAlias.
1 parent abc39f9 commit 0079136

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ AliasResult BasicAAResult::aliasGEP(
11871187
// so noalias still holds so long as the dependency distance is at least as
11881188
// big as the typesize.
11891189
if (VLeftSize.hasValue() &&
1190-
Scale.uge(VLeftSize.getValue().getKnownMinValue()))
1190+
Scale.abs().uge(VLeftSize.getValue().getKnownMinValue()))
11911191
return AliasResult::NoAlias;
11921192
}
11931193

llvm/test/Analysis/BasicAA/vscale.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,17 @@ define void @vscale_v1v2types(ptr %p) {
458458
ret void
459459
}
460460

461+
; CHECK-LABEL: vscale_negativescale
462+
; CHECK-DAG: MayAlias: <vscale x 4 x i32>* %p, <vscale x 4 x i32>* %vm16
463+
define void @vscale_negativescale(ptr %p) vscale_range(1,16) {
464+
%v = call i64 @llvm.vscale.i64()
465+
%vm = mul nsw i64 %v, -15
466+
%vm16 = getelementptr i8, ptr %p, i64 %vm
467+
load <vscale x 4 x i32>, ptr %vm16
468+
load <vscale x 4 x i32>, ptr %p
469+
ret void
470+
}
471+
461472
; CHECK-LABEL: twovscales
462473
; CHECK-DAG: MayAlias: <vscale x 4 x i32>* %vp161, <vscale x 4 x i32>* %vp162
463474
; CHECK-DAG: MayAlias: <vscale x 4 x i32>* %vp161, <vscale x 4 x i32>* %vp161b

0 commit comments

Comments
 (0)