1; REQUIRES: asserts 2; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -verify-loop-info \ 3; RUN: -S -debug 2>&1 | FileCheck %s 4 5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 6target triple = "x86_64-unknown-linux-gnu" 7 8@A = common global [100 x [100 x i32]] zeroinitializer 9@B = common global [100 x i32] zeroinitializer 10@C = common global [100 x [100 x i32]] zeroinitializer 11@D = common global [100 x [100 x [100 x i32]]] zeroinitializer 12 13;; Test that a flow dependency in outer loop doesn't prevent interchange in 14;; loops i and j. 15;; 16;; for (int k = 0; k < 100; ++k) { 17;; T[k] = fn1(); 18;; for (int i = 0; i < 1000; ++i) 19;; for(int j = 1; j < 1000; ++j) 20;; Arr[j][i] = Arr[j][i]+k; 21;; fn2(T[k]); 22;; } 23 24; CHECK: Processing Inner Loop Id = 2 and OuterLoopId = 1 25; CHECK: Loops interchanged. 26 27; CHECK: Processing Inner Loop Id = 1 and OuterLoopId = 0 28; CHECK: Not interchanging loops. Cannot prove legality. 29 30@T = internal global [100 x double] zeroinitializer, align 4 31@Arr = internal global [1000 x [1000 x i32]] zeroinitializer, align 4 32 33define void @interchange_09(i32 %k) { 34entry: 35 br label %for.body 36 37for.cond.cleanup: ; preds = %for.cond.cleanup4 38 ret void 39 40for.body: ; preds = %for.cond.cleanup4, %entry 41 %indvars.iv45 = phi i64 [ 0, %entry ], [ %indvars.iv.next46, %for.cond.cleanup4 ] 42 %call = call double @fn1() 43 %arrayidx = getelementptr inbounds [100 x double], [100 x double]* @T, i64 0, i64 %indvars.iv45 44 store double %call, double* %arrayidx, align 8 45 br label %for.cond6.preheader 46 47for.cond6.preheader: ; preds = %for.cond.cleanup8, %for.body 48 %indvars.iv42 = phi i64 [ 0, %for.body ], [ %indvars.iv.next43, %for.cond.cleanup8 ] 49 br label %for.body9 50 51for.cond.cleanup4: ; preds = %for.cond.cleanup8 52 %tmp = load double, double* %arrayidx, align 8 53 call void @fn2(double %tmp) 54 %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1 55 %exitcond47 = icmp ne i64 %indvars.iv.next46, 100 56 br i1 %exitcond47, label %for.body, label %for.cond.cleanup 57 58for.cond.cleanup8: ; preds = %for.body9 59 %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1 60 %exitcond44 = icmp ne i64 %indvars.iv.next43, 1000 61 br i1 %exitcond44, label %for.cond6.preheader, label %for.cond.cleanup4 62 63for.body9: ; preds = %for.body9, %for.cond6.preheader 64 %indvars.iv = phi i64 [ 1, %for.cond6.preheader ], [ %indvars.iv.next, %for.body9 ] 65 %arrayidx13 = getelementptr inbounds [1000 x [1000 x i32]], [1000 x [1000 x i32]]* @Arr, i64 0, i64 %indvars.iv, i64 %indvars.iv42 66 %tmp1 = load i32, i32* %arrayidx13, align 4 67 %tmp2 = trunc i64 %indvars.iv45 to i32 68 %add = add nsw i32 %tmp1, %tmp2 69 store i32 %add, i32* %arrayidx13, align 4 70 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 71 %exitcond = icmp ne i64 %indvars.iv.next, 1000 72 br i1 %exitcond, label %for.body9, label %for.cond.cleanup8 73} 74 75declare double @fn1() readnone 76declare void @fn2(double) readnone 77