[llvm] ad86d3e - [BasicAA] Add wrapping test for #72831.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 05:39:23 PST 2023
Author: Florian Hahn
Date: 2023-11-21T13:38:57Z
New Revision: ad86d3e94f21fb13e504b0b1044ef7c10bc86a98
URL: https://github.com/llvm/llvm-project/commit/ad86d3e94f21fb13e504b0b1044ef7c10bc86a98
DIFF: https://github.com/llvm/llvm-project/commit/ad86d3e94f21fb13e504b0b1044ef7c10bc86a98.diff
LOG: [BasicAA] Add wrapping test for #72831.
Add test with GEP where the index may wrap.
Added:
Modified:
llvm/test/Analysis/BasicAA/gep-modulo.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/BasicAA/gep-modulo.ll b/llvm/test/Analysis/BasicAA/gep-modulo.ll
index dcbc0a9090852e4..a84e0fc53cdc096 100644
--- a/llvm/test/Analysis/BasicAA/gep-modulo.ll
+++ b/llvm/test/Analysis/BasicAA/gep-modulo.ll
@@ -362,4 +362,35 @@ define i8 @mul_nsw_var_nonzero_minabsvarindex_one_index(ptr %arr, i8 %x, i64 %v)
ret i8 %l
}
+; FIXME: %gep and %p can alias.
+define i8 @test_pr72831_may_wrap(i64 %off) {
+; CHECK-LABEL: Function: test_pr72831_may_wrap: 2 pointers, 0 call sites
+; CHECK-NEXT: NoAlias: i8* %gep, i8* %p
+entry:
+ %p = alloca [2 x i8], align 1
+ %ext = zext i1 false to i64
+ %add.1 = add nuw nsw i64 %off, 1
+ %add.2 = add nuw nsw i64 %add.1, %ext
+ %idx = shl i64 %add.2, 32
+ %gep = getelementptr inbounds [2 x i8], ptr %p, i64 0, i64 %idx
+ store i8 0, ptr %gep, align 1
+ %l = load i8, ptr %p, align 1
+ ret i8 %l
+}
+
+define i8 @test_pr72831_no_wrap(i64 %off) {
+; CHECK-LABEL: Function: test_pr72831_no_wrap: 2 pointers, 0 call sites
+; CHECK-NEXT: NoAlias: i8* %gep, i8* %p
+entry:
+ %p = alloca [2 x i8], align 1
+ %ext = zext i1 false to i64
+ %add.1 = add nuw nsw i64 %off, 1
+ %add.2 = add nuw nsw i64 %add.1, %ext
+ %idx = shl nsw nuw i64 %add.2, 32
+ %gep = getelementptr inbounds [2 x i8], ptr %p, i64 0, i64 %idx
+ store i8 0, ptr %gep, align 1
+ %l = load i8, ptr %p, align 1
+ ret i8 %l
+}
+
declare void @llvm.assume(i1)
More information about the llvm-commits
mailing list