1; RUN: opt < %s -basic-aa -loop-interchange -pass-remarks-missed='loop-interchange' \ 2; RUN: -pass-remarks-output=%t -verify-loop-info -verify-dom-info -S | FileCheck -check-prefix=IR %s 3; RUN: FileCheck --input-file=%t %s 4 5; RUN: opt < %s -basic-aa -loop-interchange -pass-remarks-missed='loop-interchange' \ 6; RUN: -da-disable-delinearization-checks -pass-remarks-output=%t \ 7; RUN: -verify-loop-info -verify-dom-info -S | FileCheck -check-prefix=IR %s 8; RUN: FileCheck --check-prefix=DELIN --input-file=%t %s 9 10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 11target triple = "x86_64-unknown-linux-gnu" 12 13@A = common global [100 x [100 x i32]] zeroinitializer 14@B = common global [100 x [100 x [100 x i32]]] zeroinitializer 15@C = common global [100 x [100 x i64]] zeroinitializer 16 17;;--------------------------------------Test case 01------------------------------------ 18;; [FIXME] This loop though valid is currently not interchanged due to the limitation that we cannot split the inner loop latch due to multiple use of inner induction 19;; variable.(used to increment the loop counter and to access A[j+1][i+1] 20;; for(int i=0;i<N-1;i++) 21;; for(int j=1;j<N-1;j++) 22;; A[j+1][i+1] = A[j+1][i+1] + k; 23 24; IR-LABEL: @interchange_01 25; IR-NOT: split 26 27; CHECK: Name: Dependence 28; CHECK-NEXT: Function: interchange_01 29 30; DELIN: Name: UnsupportedInsBetweenInduction 31; DELIN-NEXT: Function: interchange_01 32define void @interchange_01(i32 %k, i32 %N) { 33 entry: 34 %sub = add nsw i32 %N, -1 35 %cmp26 = icmp sgt i32 %N, 1 36 br i1 %cmp26, label %for.cond1.preheader.lr.ph, label %for.end17 37 38 for.cond1.preheader.lr.ph: 39 %cmp324 = icmp sgt i32 %sub, 1 40 %0 = add i32 %N, -2 41 %1 = sext i32 %sub to i64 42 br label %for.cond1.preheader 43 44 for.cond.loopexit: 45 %cmp = icmp slt i64 %indvars.iv.next29, %1 46 br i1 %cmp, label %for.cond1.preheader, label %for.end17 47 48 for.cond1.preheader: 49 %indvars.iv28 = phi i64 [ 0, %for.cond1.preheader.lr.ph ], [ %indvars.iv.next29, %for.cond.loopexit ] 50 %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1 51 br i1 %cmp324, label %for.body4, label %for.cond.loopexit 52 53 for.body4: 54 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 1, %for.cond1.preheader ] 55 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 56 %arrayidx7 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv.next, i64 %indvars.iv.next29 57 %2 = load i32, i32* %arrayidx7 58 %add8 = add nsw i32 %2, %k 59 store i32 %add8, i32* %arrayidx7 60 %lftr.wideiv = trunc i64 %indvars.iv to i32 61 %exitcond = icmp eq i32 %lftr.wideiv, %0 62 br i1 %exitcond, label %for.cond.loopexit, label %for.body4 63 64 for.end17: 65 ret void 66} 67 68; When currently cannot interchange this loop, because transform currently 69; expects the latches to be the exiting blocks too. 70 71; IR-LABEL: @interchange_02 72; IR-NOT: split 73; 74; CHECK: Name: ExitingNotLatch 75; CHECK-NEXT: Function: interchange_02 76define void @interchange_02(i64 %k, i64 %N) { 77entry: 78 br label %for1.header 79 80for1.header: 81 %j23 = phi i64 [ 0, %entry ], [ %j.next24, %for1.inc10 ] 82 br label %for2 83 84for2: 85 %j = phi i64 [ %j.next, %latch ], [ 0, %for1.header ] 86 %arrayidx5 = getelementptr inbounds [100 x [100 x i64]], [100 x [100 x i64]]* @C, i64 0, i64 %j, i64 %j23 87 %lv = load i64, i64* %arrayidx5 88 %add = add nsw i64 %lv, %k 89 store i64 %add, i64* %arrayidx5 90 %exitcond = icmp eq i64 %j, 99 91 br i1 %exitcond, label %for1.inc10, label %latch 92latch: 93 %j.next = add nuw nsw i64 %j, 1 94 br label %for2 95 96for1.inc10: 97 %j.next24 = add nuw nsw i64 %j23, 1 98 %exitcond26 = icmp eq i64 %j23, 99 99 br i1 %exitcond26, label %for.end12, label %for1.header 100 101for.end12: 102 ret void 103} 104