1; RUN: opt -basicaa -loop-distribute -enable-loop-distribute -verify-loop-info -verify-dom-info -S < %s \ 2; RUN: | FileCheck %s 3 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. 7 8; (1st statement): 9; for (i = 0; i < n; i++) { 10; C[i] = D[i] * E[i]; 11;============================= 12; A[i + 1] = A[i] * B[i]; 13;----------------------------- 14; if (F[i]) 15; G[i] = H[i] * J[i]; 16; } 17 18target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 19target triple = "x86_64-apple-macosx10.10.0" 20 21define void @f(i32* noalias %a, 22 i32* noalias %b, 23 i32* noalias %c, 24 i32* noalias %d, 25 i32* noalias %e, 26 i32* noalias %g, 27 i32* noalias %h, 28 i32* noalias %j, 29 i64 %x) { 30entry: 31 br label %for.body 32 33; Ensure that we have only two partitions, the first with one multiplication 34; and the second with two. 35 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 39; CHECK: entry.split: 40; CHECK: br label %for.body 41; CHECK: for.body: 42; CHECK: %mulA = mul i32 %loadB, %loadA 43; CHECK: %mulG = mul i32 %loadH, %loadJ 44; CHECK: for.end: 45 46for.body: ; preds = %for.body, %entry 47 %ind = phi i64 [ 0, %entry ], [ %add, %if.end ] 48 49 %arrayidxD = getelementptr inbounds i32, i32* %d, i64 %ind 50 %loadD = load i32, i32* %arrayidxD, align 4 51 52 %arrayidxE = getelementptr inbounds i32, i32* %e, i64 %ind 53 %loadE = load i32, i32* %arrayidxE, align 4 54 55 %mulC = mul i32 %loadD, %loadE 56 57 %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind 58 store i32 %mulC, i32* %arrayidxC, align 4 59 60 61 %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind 62 %loadA = load i32, i32* %arrayidxA, align 4 63 64 %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind 65 %loadB = load i32, i32* %arrayidxB, align 4 66 67 %mulA = mul i32 %loadB, %loadA 68 69 %add = add nuw nsw i64 %ind, 1 70 %arrayidxA_plus_4 = getelementptr inbounds i32, i32* %a, i64 %add 71 store i32 %mulA, i32* %arrayidxA_plus_4, align 4 72 73 %if.cond = icmp eq i64 %ind, %x 74 br i1 %if.cond, label %if.then, label %if.end 75 76if.then: 77 %arrayidxH = getelementptr inbounds i32, i32* %h, i64 %ind 78 %loadH = load i32, i32* %arrayidxH, align 4 79 80 %arrayidxJ = getelementptr inbounds i32, i32* %j, i64 %ind 81 %loadJ = load i32, i32* %arrayidxJ, align 4 82 83 %mulG = mul i32 %loadH, %loadJ 84 85 %arrayidxG = getelementptr inbounds i32, i32* %g, i64 %ind 86 store i32 %mulG, i32* %arrayidxG, align 4 87 br label %if.end 88 89if.end: 90 %exitcond = icmp eq i64 %add, 20 91 br i1 %exitcond, label %for.end, label %for.body 92 93for.end: ; preds = %for.body 94 ret void 95} 96