1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-delicm -analyze < %s | FileCheck -match-full-lines %s
2;
3; Check that PHI mapping works even in presence of a memset whose'
4; zero value is used.
5;
6declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1)
7
8define void @func(i8* noalias nonnull %A) {
9entry:
10  br label %outer.for
11
12outer.for:
13  %j = phi i32 [0, %entry], [%j.inc, %outer.inc]
14  %j.cmp = icmp slt i32 %j, 2
15  br i1 %j.cmp, label %bodyA, label %outer.exit
16
17
18    bodyA:
19      %A_idx = getelementptr inbounds i8, i8* %A, i32 %j
20      %cond = icmp eq i32 21, 21
21      br i1 %cond, label %bodyB, label %bodyC
22
23    bodyB:
24      call void @llvm.memset.p0i8.i64(i8* %A_idx, i8 0, i64 1, i32 1, i1 false)
25      br label %bodyC
26
27    bodyC:
28      %phi = phi i8 [1, %bodyA], [0, %bodyB]
29      %a = load i8, i8* %A_idx
30      store i8 %phi, i8* %A_idx
31      br label %outer.inc
32
33
34outer.inc:
35  %j.inc = add nuw nsw i32 %j, 1
36  br label %outer.for
37
38outer.exit:
39  br label %return
40
41return:
42  ret void
43}
44
45
46; CHECK: Statistics {
47; CHECK:     Compatible overwrites: 1
48; CHECK:     Overwrites mapped to:  1
49; CHECK:     PHI scalars mapped:    1
50; CHECK: }
51
52; CHECK:      After accesses {
53; CHECK-NEXT:     Stmt_bodyA
54; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
55; CHECK-NEXT:                 { Stmt_bodyA[i0] -> MemRef_phi__phi[] };
56; CHECK-NEXT:            new: { Stmt_bodyA[i0] -> MemRef_A[o0] : false };
57; CHECK-NEXT:     Stmt_bodyB
58; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
59; CHECK-NEXT:                 { Stmt_bodyB[i0] -> MemRef_A[i0] };
60; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
61; CHECK-NEXT:                 { Stmt_bodyB[i0] -> MemRef_phi__phi[] };
62; CHECK-NEXT:            new: { Stmt_bodyB[i0] -> MemRef_A[i0] };
63; CHECK-NEXT:     Stmt_bodyC
64; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
65; CHECK-NEXT:                 { Stmt_bodyC[i0] -> MemRef_phi__phi[] };
66; CHECK-NEXT:            new: { Stmt_bodyC[i0] -> MemRef_A[i0] };
67; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
68; CHECK-NEXT:                 { Stmt_bodyC[i0] -> MemRef_A[i0] };
69; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
70; CHECK-NEXT:                 { Stmt_bodyC[i0] -> MemRef_A[i0] };
71; CHECK-NEXT: }
72