[PATCH] D93162: [BasicAA] Handle known non-zero variable index
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 13 04:22:52 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb939ebfd7f4: [BasicAA] Handle known non-zero variable index (authored by nikic).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93162/new/
https://reviews.llvm.org/D93162
Files:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/bug.23626.ll
llvm/test/Analysis/BasicAA/sequential-gep.ll
Index: llvm/test/Analysis/BasicAA/sequential-gep.ll
===================================================================
--- llvm/test/Analysis/BasicAA/sequential-gep.ll
+++ llvm/test/Analysis/BasicAA/sequential-gep.ll
@@ -111,10 +111,9 @@
}
; CHECK-LABEL: non_zero_index_simple
-; CHECK: MayAlias: i32* %gep, i32* %p
-; CHECK: MayAlias: i16* %gep.16, i32* %p
+; CHECK: NoAlias: i32* %gep, i32* %p
+; CHECK: NoAlias: i16* %gep.16, i32* %p
; CHECK: MayAlias: i32* %p, i64* %gep.64
-; TODO: First two could be NoAlias.
define void @non_zero_index_simple(i32* %p, i32* %q) {
%knownnonzero = load i32, i32* %q, !range !0
%gep = getelementptr i32, i32* %p, i32 %knownnonzero
@@ -125,8 +124,7 @@
; CHECK-LABEL: non_zero_index_with_offset
; CHECK: MayAlias: i32* %gep, i32* %p
-; CHECK: MayAlias: i16* %gep.16, i32* %p
-; TODO: Last could be NoAlias.
+; CHECK: NoAlias: i16* %gep.16, i32* %p
define void @non_zero_index_with_offset(i32* %p, i32* %q) {
%knownnonzero = load i32, i32* %q, !range !0
%p.8 = bitcast i32* %p to i8*
Index: llvm/test/Analysis/BasicAA/bug.23626.ll
===================================================================
--- llvm/test/Analysis/BasicAA/bug.23626.ll
+++ llvm/test/Analysis/BasicAA/bug.23626.ll
@@ -4,9 +4,9 @@
; CHECK-LABEL: compute1
; CHECK: MayAlias: i32* %arrayidx8, i32* %out
-; CHECK: MayAlias: i32* %arrayidx11, i32* %out
+; CHECK: NoAlias: i32* %arrayidx11, i32* %out
; CHECK: MayAlias: i32* %arrayidx11, i32* %arrayidx8
-; CHECK: MayAlias: i32* %arrayidx14, i32* %out
+; CHECK: NoAlias: i32* %arrayidx14, i32* %out
; CHECK: MayAlias: i32* %arrayidx14, i32* %arrayidx8
; CHECK: MayAlias: i32* %arrayidx11, i32* %arrayidx14
define void @compute1(i32 %num.0.lcssa, i32* %out) {
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1288,8 +1288,12 @@
if (V1Size.hasValue() && V2Size.hasValue()) {
// Try to determine whether abs(VarIndex) > 0.
Optional<APInt> MinAbsVarIndex;
- // TODO: Could handle single non-zero index as well.
- if (DecompGEP1.VarIndices.size() == 2) {
+ if (DecompGEP1.VarIndices.size() == 1) {
+ // VarIndex = Scale*V. If V != 0 then abs(VarIndex) >= abs(Scale).
+ const VariableGEPIndex &Var = DecompGEP1.VarIndices[0];
+ if (isKnownNonZero(Var.V, DL))
+ MinAbsVarIndex = Var.Scale.abs();
+ } else if (DecompGEP1.VarIndices.size() == 2) {
// VarIndex = Scale*V0 + (-Scale)*V1.
// If V0 != V1 then abs(VarIndex) >= abs(Scale).
// Check that VisitedPhiBBs is empty, to avoid reasoning about
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93162.311438.patch
Type: text/x-patch
Size: 2729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201213/8c87296f/attachment.bin>
More information about the llvm-commits
mailing list