llvm-project
55 строк · 1.6 Кб
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:
15br label %for
16
17for:
18%j = phi i32 [0, %entry], [%j.inc, %inc]
19%j.cmp = icmp slt i32 %j, %n
20br i1 %j.cmp, label %body, label %exit
21
22body:
23%A_1 = getelementptr inbounds double, ptr %A, i32 1
24store double 21.0, ptr %A
25store double 42.0, ptr %A_1
26store double 21.0, ptr %A
27store double 42.0, ptr %A_1
28br label %inc
29
30inc:
31%j.inc = add nuw nsw i32 %j, 1
32br label %for
33
34exit:
35br label %return
36
37return:
38ret 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