[llvm] [BasicAA] Fix Scale check in vscale aliasing. (PR #81174)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 11:03:55 PST 2024
https://github.com/davemgreen created https://github.com/llvm/llvm-project/pull/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.
>From fb85bbb9155f5b882bb9f05f15ad58b009af8c58 Mon Sep 17 00:00:00 2001
From: David Green <david.green at arm.com>
Date: Thu, 8 Feb 2024 18:58:57 +0000
Subject: [PATCH] [BasicAA] Fix Scale check in vscale aliasing.
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.
---
llvm/lib/Analysis/BasicAliasAnalysis.cpp | 2 +-
llvm/test/Analysis/BasicAA/vscale.ll | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index ae31814bb0673..682b0a2ecacb3 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -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;
}
diff --git a/llvm/test/Analysis/BasicAA/vscale.ll b/llvm/test/Analysis/BasicAA/vscale.ll
index ce0c6f145d1c8..b2f5c66be5bb2 100644
--- a/llvm/test/Analysis/BasicAA/vscale.ll
+++ b/llvm/test/Analysis/BasicAA/vscale.ll
@@ -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
More information about the llvm-commits
mailing list