xref: /llvm-project/polly/test/Simplify/overwritten_implicit_and_explicit.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=polly-import-jscop,print<polly-simplify>' -polly-import-jscop-postfix=transformed -disable-output < %s | FileCheck -match-full-lines %s
2;
3; Remove a store that is overwritten by another store in the same statement.
4; Check that this works even if one of the writes is a scalar MemoryKind.
5;
6; for (int j = 0; j < n; j += 1) {
7; body:
8;   val = 21.0 + 21.0;
9;   A[1] = val;
10;
11; user:
12;   A[0] = val;
13; }
14;
15define void @overwritten_implicit_and_explicit(i32 %n, ptr noalias nonnull %A, ptr noalias nonnull %C) {
16entry:
17  br label %for
18
19for:
20  %j = phi i32 [0, %entry], [%j.inc, %inc]
21  %j.cmp = icmp slt i32 %j, %n
22  br i1 %j.cmp, label %body, label %exit
23
24    body:
25      %val = fadd double 21.0, 21.0
26      store double %val, ptr %A
27      br label %user
28
29    user:
30      store double %val, ptr %C
31      br label %inc
32
33inc:
34  %j.inc = add nuw nsw i32 %j, 1
35  br label %for
36
37exit:
38  br label %return
39
40return:
41  ret void
42}
43
44
45; CHECK: Statistics {
46; CHECK:     Overwrites removed: 1
47; CHECK: }
48
49; CHECK:          Stmt_body
50; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
51; CHECK-NEXT:                 [n] -> { Stmt_body[i0] -> MemRef_val[] };
52; CHECK-NEXT:            new: [n] -> { Stmt_body[i0] -> MemRef_A[0] };
53; CHECK-NEXT:     Stmt_user
54