[llvm] 6fc29e3 - [BasicAA] Add a few more interesting modulo tests.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 26 09:57:11 PDT 2021


Author: Florian Hahn
Date: 2021-03-26T16:56:49Z
New Revision: 6fc29e30dca8a724b16784ef6a9329d2fc023f66

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

LOG: [BasicAA] Add a few more interesting modulo tests.

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 2e9d796ec4f8..2446302e5fef 100644
--- a/llvm/test/Analysis/BasicAA/gep-modulo.ll
+++ b/llvm/test/Analysis/BasicAA/gep-modulo.ll
@@ -50,8 +50,13 @@ define void @may_overflow_mul_sub_i8([16 x i8]* %ptr, i8 %idx) {
 }
 
 define void @nuw_nsw_mul_sub_i8([16 x i8]* %ptr, i8 %idx) {
-  %mul = mul i8 %idx, 5
-  %sub = sub i8 %mul, 1
+; CHECK-LABEL: Function: nuw_nsw_mul_sub_i8: 3 pointers, 0 call sites
+; CHECK-NEXT:    MayAlias:  [16 x i8]* %ptr, i8* %gep.idx
+; CHECK-NEXT:    PartialAlias: [16 x i8]* %ptr, i8* %gep.3
+; CHECK-NEXT:    NoAlias:  i8* %gep.3, i8* %gep.idx
+;
+  %mul = mul nuw nsw i8 %idx, 5
+  %sub = sub nuw nsw i8 %mul, 1
   %gep.idx = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i8 %sub
   store i8 0, i8* %gep.idx, align 1
   %gep.3 = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i32 3
@@ -62,6 +67,11 @@ define void @nuw_nsw_mul_sub_i8([16 x i8]* %ptr, i8 %idx) {
 ; %gep.idx and %gep.3 must-alias if %mul overflows
 ; (e.g. %idx == 3689348814741910323).
 define void @may_overflow_mul_sub_i64([16 x i8]* %ptr, i64 %idx) {
+; CHECK-LABEL: Function: may_overflow_mul_sub_i64: 3 pointers, 0 call sites
+; CHECK-NEXT:    MayAlias:  [16 x i8]* %ptr, i8* %gep.idx
+; CHECK-NEXT:    PartialAlias: [16 x i8]* %ptr, i8* %gep.3
+; CHECK-NEXT:    NoAlias:  i8* %gep.3, i8* %gep.idx
+;
   %mul = mul i64 %idx, 5
   %sub = sub i64 %mul, 1
   %gep.idx = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i64 %sub
@@ -88,6 +98,22 @@ define void @may_overflow_i32_sext([16 x i8]* %ptr, i32 %idx) {
   ret void
 }
 
+define void @nuw_nsw_i32_sext([16 x i8]* %ptr, i32 %idx) {
+; CHECK-LABEL: Function: nuw_nsw_i32_sext: 3 pointers, 0 call sites
+; CHECK-NEXT:    NoAlias:  [16 x i8]* %ptr, i8* %gep.idx
+; CHECK-NEXT:    PartialAlias:  [16 x i8]* %ptr, i8* %gep.3
+; CHECK-NEXT:    NoAlias:	i8* %gep.3, i8* %gep.idx
+;
+  %mul = mul nuw nsw i32 %idx, 678152731
+  %sub = sub nuw nsw i32 %mul, 1582356375
+  %sub.ext = sext i32 %sub to i64
+  %gep.idx = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i64 %sub.ext
+  store i8 0, i8* %gep.idx, align 1
+  %gep.3 = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i32 3
+  store i8 1, i8* %gep.3, align 1
+  ret void
+}
+
 ; %gep.idx and %gep.3 must-alias if %mul overflows (e.g. %idx == 110).
 define void @may_overflow_i32_zext([16 x i8]* %ptr, i32 %idx) {
 ; CHECK-LABEL: Function: may_overflow_i32_zext: 3 pointers, 0 call sites
@@ -104,3 +130,19 @@ define void @may_overflow_i32_zext([16 x i8]* %ptr, i32 %idx) {
   store i8 1, i8* %gep.3, align 1
   ret void
 }
+
+define void @nuw_nsw_i32_zext([16 x i8]* %ptr, i32 %idx) {
+; CHECK-LABEL: Function: nuw_nsw_i32_zext: 3 pointers, 0 call sites
+; CHECK-NEXT:    NoAlias:  [16 x i8]* %ptr, i8* %gep.idx
+; CHECK-NEXT:    PartialAlias:  [16 x i8]* %ptr, i8* %gep.3
+; CHECK-NEXT:    NoAlias:	i8* %gep.3, i8* %gep.idx
+;
+  %mul = mul nuw nsw i32 %idx, 678152731
+  %sub = sub nuw nsw i32 %mul, 1582356375
+  %sub.ext = zext i32 %sub to i64
+  %gep.idx = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i64 %sub.ext
+  store i8 0, i8* %gep.idx, align 1
+  %gep.3 = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i32 3
+  store i8 1, i8* %gep.3, align 1
+  ret void
+}


        


More information about the llvm-commits mailing list