[llvm-branch-commits] [llvm] a3614a3 - [BasicAA] Pass context instruction to isKnownNonZero()

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 25 04:06:44 PST 2020


Author: Nikita Popov
Date: 2020-12-25T12:58:19+01:00
New Revision: a3614a31c46a41b76fd6a6c6b30b353bc4131b94

URL: https://github.com/llvm/llvm-project/commit/a3614a31c46a41b76fd6a6c6b30b353bc4131b94
DIFF: https://github.com/llvm/llvm-project/commit/a3614a31c46a41b76fd6a6c6b30b353bc4131b94.diff

LOG: [BasicAA] Pass context instruction to isKnownNonZero()

This allows us to handle additional cases like assumes.

Added: 
    

Modified: 
    llvm/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/test/Analysis/BasicAA/sequential-gep.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 4a30e075af0a..2dca64447fde 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1280,7 +1280,7 @@ AliasResult BasicAAResult::aliasGEP(
       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))
+        if (isKnownNonZero(Var.V, DL, 0, &AC, Var.CxtI, DT))
           MinAbsVarIndex = Var.Scale.abs();
       } else if (DecompGEP1.VarIndices.size() == 2) {
         // VarIndex = Scale*V0 + (-Scale)*V1.

diff  --git a/llvm/test/Analysis/BasicAA/sequential-gep.ll b/llvm/test/Analysis/BasicAA/sequential-gep.ll
index b6e84fa97138..e5b744ba6bf8 100644
--- a/llvm/test/Analysis/BasicAA/sequential-gep.ll
+++ b/llvm/test/Analysis/BasicAA/sequential-gep.ll
@@ -135,4 +135,15 @@ define void @non_zero_index_with_offset(i32* %p, i32* %q) {
   ret void
 }
 
+; CHECK-LABEL: non_zero_index_assume
+; CHECK: NoAlias: i32* %gep, i32* %p
+define void @non_zero_index_assume(i32* %p, i32 %knownnonzero) {
+  %cmp = icmp ne i32 %knownnonzero, 0
+  call void @llvm.assume(i1 %cmp)
+  %gep = getelementptr i32, i32* %p, i32 %knownnonzero
+  ret void
+}
+
+declare void @llvm.assume(i1)
+
 !0 = !{ i32 1, i32 5 }


        


More information about the llvm-branch-commits mailing list