[llvm-branch-commits] [llvm] b0ce2b7 - [BasicAA] Add tests for non-zero var index (NFC)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 12 06:04:57 PST 2020


Author: Nikita Popov
Date: 2020-12-12T15:00:46+01:00
New Revision: b0ce2b72e8b70a4fb4b6ef385e0989955bd7e01b

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

LOG: [BasicAA] Add tests for non-zero var index (NFC)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/BasicAA/sequential-gep.ll b/llvm/test/Analysis/BasicAA/sequential-gep.ll
index bc455a04adc4..2b61b5327c10 100644
--- a/llvm/test/Analysis/BasicAA/sequential-gep.ll
+++ b/llvm/test/Analysis/BasicAA/sequential-gep.ll
@@ -110,4 +110,31 @@ define void @add_non_zero_with_offset(i32* %p, i32 %addend, i32* %q) {
   ret void
 }
 
+; CHECK-LABEL: non_zero_index_simple
+; CHECK: MayAlias: i32* %gep, i32* %p
+; CHECK: MayAlias: 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
+  %gep.16 = bitcast i32* %gep to i16*
+  %gep.64 = bitcast i32* %gep to i64*
+  ret void
+}
+
+; 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.
+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*
+  %p.off.8 = getelementptr i8, i8* %p.8, i32 2
+  %p.off = bitcast i8* %p.off.8 to i32*
+  %gep = getelementptr i32, i32* %p.off, i32 %knownnonzero
+  %gep.16 = bitcast i32* %gep to i16*
+  ret void
+}
+
 !0 = !{ i32 1, i32 5 }


        


More information about the llvm-branch-commits mailing list