1; RUN: opt -loop-load-elim -S < %s | FileCheck %s
2
3;  No loop-carried forwarding: The intervening store to A[i] kills the stored
4;  value from the previous iteration.
5;
6;   for (unsigned i = 0; i < 100; i++) {
7;     A[i] = 1;
8;     A[i+1] = A[i] + B[i];
9;   }
10
11target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
12
13define void @f(i32* noalias nocapture %A, i32* noalias nocapture readonly %B, i64 %N) {
14entry:
15  br label %for.body
16
17for.body:                                         ; preds = %for.body, %entry
18; CHECK-NOT: %store_forwarded
19  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
20  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
21  store i32 1, i32* %arrayidx, align 4
22  %a = load i32, i32* %arrayidx, align 4
23  %arrayidxB = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
24  %b = load i32, i32* %arrayidxB, align 4
25; CHECK: %add = add i32 %b, %a
26  %add = add i32 %b, %a
27  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
28  %arrayidx_next = getelementptr inbounds i32, i32* %A, i64 %indvars.iv.next
29  store i32 %add, i32* %arrayidx_next, align 4
30  %exitcond = icmp eq i64 %indvars.iv.next, %N
31  br i1 %exitcond, label %for.end, label %for.body
32
33for.end:                                          ; preds = %for.body
34  ret void
35}
36