[llvm-branch-commits] [llvm] 8925d23 - [BasicAA] Add recphi tests with nested loops (NFC)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 5 02:13:56 PST 2020


Author: Nikita Popov
Date: 2020-12-05T11:09:15+01:00
New Revision: 8925d2347432b69d7e4b721a4ced85df0ad782b1

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

LOG: [BasicAA] Add recphi tests with nested loops (NFC)

Added: 
    

Modified: 
    llvm/test/Analysis/BasicAA/recphi.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/BasicAA/recphi.ll b/llvm/test/Analysis/BasicAA/recphi.ll
index 13a58fbcf118..7f8bc9d7b668 100644
--- a/llvm/test/Analysis/BasicAA/recphi.ll
+++ b/llvm/test/Analysis/BasicAA/recphi.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -basic-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
+; RUN: opt < %s -basic-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,NO-PHI-VALUES
+; RUN: opt < %s -phi-values -basic-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,PHI-VALUES
 
 ; CHECK-LABEL: Function: simple: 5 pointers, 0 call sites
 ; CHECK:         NoAlias:      float* %src1, float* %src2
@@ -232,5 +233,63 @@ exit:
   ret i32* %result
 }
 
+; CHECK-LABEL: Function: nested_loop
+; CHECK: NoAlias:  i8* %a, i8* %p.base
+; CHECK: NoAlias:  i8* %a, i8* %p.outer
+; CHECK: NoAlias:  i8* %a, i8* %p.outer.next
+; NO-PHI-VALUES: MayAlias: i8* %a, i8* %p.inner
+; PHI-VALUES: NoAlias: i8* %a, i8* %p.inner
+; CHECK: NoAlias:  i8* %a, i8* %p.inner.next
+define void @nested_loop(i1 %c, i1 %c2, i8* noalias %p.base) {
+entry:
+  %a = alloca i8
+  br label %outer_loop
+
+outer_loop:
+  %p.outer = phi i8* [ %p.base, %entry ], [ %p.outer.next, %outer_loop_latch ]
+  br label %inner_loop
+
+inner_loop:
+  %p.inner = phi i8* [ %p.outer, %outer_loop ], [ %p.inner.next, %inner_loop ]
+  %p.inner.next = getelementptr inbounds i8, i8* %p.inner, i64 1
+  br i1 %c, label %inner_loop, label %outer_loop_latch
+
+outer_loop_latch:
+  %p.outer.next = getelementptr inbounds i8, i8* %p.inner, i64 10
+  br i1 %c2, label %outer_loop, label %exit
+
+exit:
+  ret void
+}
+
+; Same as the previous test case, but avoiding phi of phi.
+; CHECK-LABEL: Function: nested_loop2
+; CHECK: NoAlias:  i8* %a, i8* %p.base
+; CHECK: NoAlias:  i8* %a, i8* %p.outer
+; CHECK: NoAlias:  i8* %a, i8* %p.outer.next
+; CHECK: MayAlias: i8* %a, i8* %p.inner
+; CHECK: NoAlias:  i8* %a, i8* %p.inner.next
+; TODO: (a, p.inner) could be NoAlias
+define void @nested_loop2(i1 %c, i1 %c2, i8* noalias %p.base) {
+entry:
+  %a = alloca i8
+  br label %outer_loop
+
+outer_loop:
+  %p.outer = phi i8* [ %p.base, %entry ], [ %p.outer.next, %outer_loop_latch ]
+  %p.outer.next = getelementptr inbounds i8, i8* %p.outer, i64 10
+  br label %inner_loop
+
+inner_loop:
+  %p.inner = phi i8* [ %p.outer.next, %outer_loop ], [ %p.inner.next, %inner_loop ]
+  %p.inner.next = getelementptr inbounds i8, i8* %p.inner, i64 1
+  br i1 %c, label %inner_loop, label %outer_loop_latch
+
+outer_loop_latch:
+  br i1 %c2, label %outer_loop, label %exit
+
+exit:
+  ret void
+}
 
 declare i16 @call(i32)


        


More information about the llvm-branch-commits mailing list