1 ; RUN: opt -passes=loop-distribute -enable-loop-distribute -verify-loop-info -verify-dom-info -S < %s \
4 ; We should distribute this loop along === but not along ---. The last
5 ; partition won't be vectorized due to conditional stores so it's better to
6 ; keep it with the second partition which has a dependence cycle.
9 ; for (i = 0; i < n; i++) {
11 ;=============================
12 ; A[i + 1] = A[i] * B[i];
13 ;-----------------------------
18 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
19 target triple = "x86_64-apple-macosx10.10.0"
21 define void @f(ptr noalias %a,
33 ; Ensure that we have only two partitions, the first with one multiplication
34 ; and the second with two.
36 ; CHECK: for.body.ldist1:
37 ; CHECK: %mulC.ldist1 = mul i32 %loadD.ldist1, %loadE.ldist1
38 ; CHECK: br i1 %exitcond.ldist1, label %entry.split, label %for.body.ldist1
40 ; CHECK: br label %for.body
42 ; CHECK: %mulA = mul i32 %loadB, %loadA
43 ; CHECK: %mulG = mul i32 %loadH, %loadJ
46 for.body: ; preds = %for.body, %entry
47 %ind = phi i64 [ 0, %entry ], [ %add, %if.end ]
49 %arrayidxD = getelementptr inbounds i32, ptr %d, i64 %ind
50 %loadD = load i32, ptr %arrayidxD, align 4
52 %arrayidxE = getelementptr inbounds i32, ptr %e, i64 %ind
53 %loadE = load i32, ptr %arrayidxE, align 4
55 %mulC = mul i32 %loadD, %loadE
57 %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %ind
58 store i32 %mulC, ptr %arrayidxC, align 4
61 %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %ind
62 %loadA = load i32, ptr %arrayidxA, align 4
64 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %ind
65 %loadB = load i32, ptr %arrayidxB, align 4
67 %mulA = mul i32 %loadB, %loadA
69 %add = add nuw nsw i64 %ind, 1
70 %arrayidxA_plus_4 = getelementptr inbounds i32, ptr %a, i64 %add
71 store i32 %mulA, ptr %arrayidxA_plus_4, align 4
73 %if.cond = icmp eq i64 %ind, %x
74 br i1 %if.cond, label %if.then, label %if.end
77 %arrayidxH = getelementptr inbounds i32, ptr %h, i64 %ind
78 %loadH = load i32, ptr %arrayidxH, align 4
80 %arrayidxJ = getelementptr inbounds i32, ptr %j, i64 %ind
81 %loadJ = load i32, ptr %arrayidxJ, align 4
83 %mulG = mul i32 %loadH, %loadJ
85 %arrayidxG = getelementptr inbounds i32, ptr %g, i64 %ind
86 store i32 %mulG, ptr %arrayidxG, align 4
90 %exitcond = icmp eq i64 %add, 20
91 br i1 %exitcond, label %for.end, label %for.body
93 for.end: ; preds = %for.body