xref: /llvm-project/polly/test/Simplify/overwritten_loadbetween.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly "-passes=scop(print<polly-simplify>)" -disable-output -aa-pipeline=basic-aa < %s | FileCheck -match-full-lines %s
2;
3; Do not remove overwrites when the value is read before.
4;
5; for (int j = 0; j < n; j += 1) {
6;body:
7;   A[0] = 21.0;
8;   val = A[0];
9;   A[0] = 42.0;
10;
11;user:
12;   B[0] = val;
13; }
14;
15define void @overwritten(i32 %n, ptr noalias nonnull %A, ptr noalias nonnull %B) {
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      store double 21.0, ptr %A
26      %val = load double, ptr %A
27      store double 42.0, ptr %A
28      br label %user
29
30    user:
31      store double %val, ptr %B
32      br label %inc
33
34inc:
35  %j.inc = add nuw nsw i32 %j, 1
36  br label %for
37
38exit:
39  br label %return
40
41return:
42  ret void
43}
44
45
46; CHECK: SCoP could not be simplified
47