blob: 58d3308f1474fcaf97770620d27c042f6dd7cf3a [file] [log] [blame]
Fangrui Songf31811f2020-06-26 20:41:37 -07001; RUN: opt -basic-aa -loop-load-elim -S < %s | FileCheck %s
Eric Christophercee313d2019-04-17 04:52:47 +00002
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4
5; Give up in the presence of unknown deps. Here, the different strides result
6; in unknown dependence:
7;
8; for (unsigned i = 0; i < 100; i++) {
9; A[i+1] = B[i] + 2;
10; A[2*i] = C[i] + 2;
11; D[i] = A[i] + 2;
12; }
13
14define void @f(i32* noalias %A, i32* noalias %B, i32* noalias %C,
15 i32* noalias %D, i64 %N) {
16
17entry:
18; for.body.ph:
19; CHECK-NOT: %load_initial =
20 br label %for.body
21
22for.body: ; preds = %for.body, %entry
23; CHECK-NOT: %store_forwarded =
24 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
25 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
26
27 %Aidx_next = getelementptr inbounds i32, i32* %A, i64 %indvars.iv.next
28 %Bidx = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
29 %Cidx = getelementptr inbounds i32, i32* %C, i64 %indvars.iv
30 %Didx = getelementptr inbounds i32, i32* %D, i64 %indvars.iv
31 %Aidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
32 %indvars.m2 = mul nuw nsw i64 %indvars.iv, 2
33 %A2idx = getelementptr inbounds i32, i32* %A, i64 %indvars.m2
34
35 %b = load i32, i32* %Bidx, align 4
36 %a_p1 = add i32 %b, 2
37 store i32 %a_p1, i32* %Aidx_next, align 4
38
39 %c = load i32, i32* %Cidx, align 4
40 %a_m2 = add i32 %c, 2
41 store i32 %a_m2, i32* %A2idx, align 4
42
43 %a = load i32, i32* %Aidx, align 4
44; CHECK-NOT: %d = add i32 %store_forwarded, 2
45; CHECK: %d = add i32 %a, 2
46 %d = add i32 %a, 2
47 store i32 %d, i32* %Didx, align 4
48
49 %exitcond = icmp eq i64 %indvars.iv.next, %N
50 br i1 %exitcond, label %for.end, label %for.body
51
52for.end: ; preds = %for.body
53 ret void
54}