1*cee313d2SEric Christopher; RUN: opt -loop-distribute -enable-loop-distribute -S -verify-loop-info -verify-dom-info < %s \ 2*cee313d2SEric Christopher; RUN: | FileCheck %s 3*cee313d2SEric Christopher 4*cee313d2SEric Christopher; Distributing this loop to avoid the dependence cycle would require to 5*cee313d2SEric Christopher; reorder S1 and S2 to form the two partitions: {S2} | {S1, S3}. The analysis 6*cee313d2SEric Christopher; provided by LoopAccessAnalysis does not allow us to reorder memory 7*cee313d2SEric Christopher; operations so make sure we bail on this loop. 8*cee313d2SEric Christopher; 9*cee313d2SEric Christopher; for (i = 0; i < n; i++) { 10*cee313d2SEric Christopher; S1: d = D[i]; 11*cee313d2SEric Christopher; S2: A[i + 1] = A[i] * B[i]; 12*cee313d2SEric Christopher; S3: C[i] = d * E[i]; 13*cee313d2SEric Christopher; } 14*cee313d2SEric Christopher 15*cee313d2SEric Christophertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 16*cee313d2SEric Christophertarget triple = "x86_64-apple-macosx10.10.0" 17*cee313d2SEric Christopher 18*cee313d2SEric Christopherdefine void @f(i32* noalias %a, 19*cee313d2SEric Christopher i32* noalias %b, 20*cee313d2SEric Christopher i32* noalias %c, 21*cee313d2SEric Christopher i32* noalias %d, 22*cee313d2SEric Christopher i32* noalias %e) { 23*cee313d2SEric Christopherentry: 24*cee313d2SEric Christopher br label %for.body 25*cee313d2SEric Christopher 26*cee313d2SEric Christopher; CHECK: entry: 27*cee313d2SEric Christopher; CHECK: br label %for.body 28*cee313d2SEric Christopher; CHECK: for.body: 29*cee313d2SEric Christopher; CHECK: br i1 %exitcond, label %for.end, label %for.body 30*cee313d2SEric Christopher; CHECK: for.end: 31*cee313d2SEric Christopher; CHECK: ret void 32*cee313d2SEric Christopher 33*cee313d2SEric Christopherfor.body: ; preds = %for.body, %entry 34*cee313d2SEric Christopher %ind = phi i64 [ 0, %entry ], [ %add, %for.body ] 35*cee313d2SEric Christopher 36*cee313d2SEric Christopher %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind 37*cee313d2SEric Christopher %loadA = load i32, i32* %arrayidxA, align 4 38*cee313d2SEric Christopher 39*cee313d2SEric Christopher %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind 40*cee313d2SEric Christopher %loadB = load i32, i32* %arrayidxB, align 4 41*cee313d2SEric Christopher 42*cee313d2SEric Christopher %mulA = mul i32 %loadB, %loadA 43*cee313d2SEric Christopher 44*cee313d2SEric Christopher %arrayidxD = getelementptr inbounds i32, i32* %d, i64 %ind 45*cee313d2SEric Christopher %loadD = load i32, i32* %arrayidxD, align 4 46*cee313d2SEric Christopher 47*cee313d2SEric Christopher %add = add nuw nsw i64 %ind, 1 48*cee313d2SEric Christopher %arrayidxA_plus_4 = getelementptr inbounds i32, i32* %a, i64 %add 49*cee313d2SEric Christopher store i32 %mulA, i32* %arrayidxA_plus_4, align 4 50*cee313d2SEric Christopher 51*cee313d2SEric Christopher %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind 52*cee313d2SEric Christopher 53*cee313d2SEric Christopher %arrayidxE = getelementptr inbounds i32, i32* %e, i64 %ind 54*cee313d2SEric Christopher %loadE = load i32, i32* %arrayidxE, align 4 55*cee313d2SEric Christopher 56*cee313d2SEric Christopher %mulC = mul i32 %loadD, %loadE 57*cee313d2SEric Christopher 58*cee313d2SEric Christopher store i32 %mulC, i32* %arrayidxC, align 4 59*cee313d2SEric Christopher 60*cee313d2SEric Christopher %exitcond = icmp eq i64 %add, 20 61*cee313d2SEric Christopher br i1 %exitcond, label %for.end, label %for.body 62*cee313d2SEric Christopher 63*cee313d2SEric Christopherfor.end: ; preds = %for.body 64*cee313d2SEric Christopher ret void 65*cee313d2SEric Christopher} 66