[llvm-branch-commits] [llvm] c795dd1 - [BasicAA] Pass AC/DT to isKnownNonEqual()

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 25 09:33:30 PST 2020


Author: Nikita Popov
Date: 2020-12-25T18:29:20+01:00
New Revision: c795dd19265d80e835ea1137f19f73624d7983e4

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

LOG: [BasicAA] Pass AC/DT to isKnownNonEqual()

This allows us to handle assumes etc in the recursive
isKnownNonZero() checks.

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 2dca64447fde..f9275daf1224 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1291,7 +1291,7 @@ AliasResult BasicAAResult::aliasGEP(
         const VariableGEPIndex &Var1 = DecompGEP1.VarIndices[1];
         if (Var0.Scale == -Var1.Scale && Var0.ZExtBits == Var1.ZExtBits &&
             Var0.SExtBits == Var1.SExtBits && VisitedPhiBBs.empty() &&
-            isKnownNonEqual(Var0.V, Var1.V, DL))
+            isKnownNonEqual(Var0.V, Var1.V, DL, &AC, /* CxtI */ nullptr, DT))
           MinAbsVarIndex = Var0.Scale.abs();
       }
 

diff  --git a/llvm/test/Analysis/BasicAA/sequential-gep.ll b/llvm/test/Analysis/BasicAA/sequential-gep.ll
index e5b744ba6bf8..d7a1af024cec 100644
--- a/llvm/test/Analysis/BasicAA/sequential-gep.ll
+++ b/llvm/test/Analysis/BasicAA/sequential-gep.ll
@@ -110,6 +110,17 @@ define void @add_non_zero_with_offset(i32* %p, i32 %addend, i32* %q) {
   ret void
 }
 
+; CHECK-LABEL: Function: add_non_zero_assume
+; CHECK: NoAlias: i32* %gep1, i32* %gep2
+define void @add_non_zero_assume(i32* %p, i32 %addend, i32 %knownnonzero) {
+  %cmp = icmp ne i32 %knownnonzero, 0
+  call void @llvm.assume(i1 %cmp)
+  %add = add i32 %addend, %knownnonzero
+  %gep1 = getelementptr i32, i32* %p, i32 %addend
+  %gep2 = getelementptr i32, i32* %p, i32 %add
+  ret void
+}
+
 ; CHECK-LABEL: non_zero_index_simple
 ; CHECK: NoAlias: i32* %gep, i32* %p
 ; CHECK: NoAlias: i16* %gep.16, i32* %p


        


More information about the llvm-branch-commits mailing list