Skip to content

[BasicAA] Fix Scale check in vscale aliasing. #81174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ AliasResult BasicAAResult::aliasGEP(
// so noalias still holds so long as the dependency distance is at least as
// big as the typesize.
if (VLeftSize.hasValue() &&
Scale.uge(VLeftSize.getValue().getKnownMinValue()))
Scale.abs().uge(VLeftSize.getValue().getKnownMinValue()))
return AliasResult::NoAlias;
}

Expand Down
11 changes: 11 additions & 0 deletions llvm/test/Analysis/BasicAA/vscale.ll
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,17 @@ define void @vscale_v1v2types(ptr %p) {
ret void
}

; CHECK-LABEL: vscale_negativescale
; CHECK-DAG: MayAlias: <vscale x 4 x i32>* %p, <vscale x 4 x i32>* %vm16
define void @vscale_negativescale(ptr %p) vscale_range(1,16) {
%v = call i64 @llvm.vscale.i64()
%vm = mul nsw i64 %v, -15
%vm16 = getelementptr i8, ptr %p, i64 %vm
load <vscale x 4 x i32>, ptr %vm16
load <vscale x 4 x i32>, ptr %p
ret void
}

; CHECK-LABEL: twovscales
; CHECK-DAG: MayAlias: <vscale x 4 x i32>* %vp161, <vscale x 4 x i32>* %vp162
; CHECK-DAG: MayAlias: <vscale x 4 x i32>* %vp161, <vscale x 4 x i32>* %vp161b
Expand Down