1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-import-jscop -polly-import-jscop-postfix=transformed -polly-simplify -analyze < %s | FileCheck -match-full-lines %s
2;
3; Combine four partial stores into two.
4; The stores write to the same array, but never the same element.
5;
6; for (int j = 0; j < n; j += 1) {
7;   A[0] = 21.0;
8;   A[1] = 42.0;
9;   A[0] = 21.0;
10;   A[1] = 42.0;
11; }
12;
13define void @coalesce_disjointelements(i32 %n, double* noalias nonnull %A) {
14entry:
15  br label %for
16
17for:
18  %j = phi i32 [0, %entry], [%j.inc, %inc]
19  %j.cmp = icmp slt i32 %j, %n
20  br i1 %j.cmp, label %body, label %exit
21
22    body:
23      %A_0 = getelementptr inbounds double, double* %A, i32 0
24      %A_1 = getelementptr inbounds double, double* %A, i32 1
25      store double 21.0, double* %A_0
26      store double 42.0, double* %A_1
27      store double 21.0, double* %A_0
28      store double 42.0, double* %A_1
29      br label %inc
30
31inc:
32  %j.inc = add nuw nsw i32 %j, 1
33  br label %for
34
35exit:
36  br label %return
37
38return:
39  ret void
40}
41
42
43; CHECK: Statistics {
44; CHECK:     Overwrites removed: 0
45; CHECK:     Partial writes coalesced: 2
46; CHECK: }
47
48; CHECK:      After accesses {
49; CHECK-NEXT:     Stmt_body
50; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
51; CHECK-NEXT:                 [n] -> { Stmt_body[i0] -> MemRef_A[0] };
52; CHECK-NEXT:            new: [n] -> { Stmt_body[i0] -> MemRef_A[0] : n <= 2147483647 };
53; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
54; CHECK-NEXT:                 [n] -> { Stmt_body[i0] -> MemRef_A[1] };
55; CHECK-NEXT:            new: [n] -> { Stmt_body[i0] -> MemRef_A[1] : n <= 2147483647 };
56; CHECK-NEXT: }
57