xref: /llvm-project/polly/test/Simplify/coalesce_disjointelements.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb '-passes=polly-import-jscop,print<polly-simplify>' -polly-import-jscop-postfix=transformed -disable-output < %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, ptr 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_1 = getelementptr inbounds double, ptr %A, i32 1
24      store double 21.0, ptr %A
25      store double 42.0, ptr %A_1
26      store double 21.0, ptr %A
27      store double 42.0, ptr %A_1
28      br label %inc
29
30inc:
31  %j.inc = add nuw nsw i32 %j, 1
32  br label %for
33
34exit:
35  br label %return
36
37return:
38  ret void
39}
40
41
42; CHECK: Statistics {
43; CHECK:     Overwrites removed: 0
44; CHECK:     Partial writes coalesced: 2
45; CHECK: }
46
47; CHECK:      After accesses {
48; CHECK-NEXT:     Stmt_body
49; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
50; CHECK-NEXT:                 [n] -> { Stmt_body[i0] -> MemRef_A[0] };
51; CHECK-NEXT:            new: [n] -> { Stmt_body[i0] -> MemRef_A[0] };
52; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
53; CHECK-NEXT:                 [n] -> { Stmt_body[i0] -> MemRef_A[1] };
54; CHECK-NEXT:            new: [n] -> { Stmt_body[i0] -> MemRef_A[1] };
55; CHECK-NEXT: }
56