[llvm] 0056e7e - [BasicAA] Add another GEP modulo test with shl with odd op.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 7 14:32:10 PDT 2021


Author: Florian Hahn
Date: 2021-04-07T22:31:51+01:00
New Revision: 0056e7e15ac0c89cb6eab37d79900d174adb713e

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

LOG: [BasicAA] Add another GEP modulo test with shl with odd op.

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 4c3e547e7036..27af5adf90d2 100644
--- a/llvm/test/Analysis/BasicAA/gep-modulo.ll
+++ b/llvm/test/Analysis/BasicAA/gep-modulo.ll
@@ -172,6 +172,21 @@ define void @may_overflow_shl_sub_i64([16 x i8]* %ptr, i64 %idx) {
   ret void
 }
 
+define void @shl_sub_nsw_nuw_i64([16 x i8]* %ptr, i64 %idx) {
+; CHECK-LABEL: Function: shl_sub_nsw_nuw_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 = shl i64 %idx, 3
+  %sub = sub nsw nuw i64 %mul, 1
+  %gep.idx = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i64 %sub
+  store i8 0, i8* %gep.idx, align 1
+  %gep.3 = getelementptr [16 x i8], [16 x i8]* %ptr, i32 0, i64 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_sext([16 x i8]* %ptr, i32 %idx) {
 ; CHECK-LABEL: Function: may_overflow_i32_sext: 3 pointers, 0 call sites


        


More information about the llvm-commits mailing list