; RUN: opt < %s -loop-interchange -pass-remarks-output=%t -verify-dom-info -verify-loop-info \ ; RUN: -pass-remarks=loop-interchange -pass-remarks-missed=loop-interchange ; RUN: FileCheck -input-file %t %s ; RUN: opt < %s -loop-interchange -pass-remarks-output=%t -verify-dom-info -verify-loop-info \ ; RUN: -pass-remarks=loop-interchange -pass-remarks-missed=loop-interchange \ ; RUN: -da-disable-delinearization-checks ; RUN: FileCheck --check-prefix=DELIN -input-file %t %s ;; We test profitability model in these test cases. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @A = common global [100 x [100 x i32]] zeroinitializer @B = common global [100 x [100 x i32]] zeroinitializer ;;---------------------------------------Test case 01--------------------------------- ;; Loops interchange will result in code vectorization and hence profitable. Check for interchange. ;; for(int i=1;i<100;i++) ;; for(int j=1;j<100;j++) ;; A[j][i] = A[j - 1][i] + B[j][i]; ; CHECK: Name: Dependence ; CHECK-NEXT: Function: interchange_01 ; DELIN: Name: Interchanged ; DELIN-NEXT: Function: interchange_01 define void @interchange_01() { entry: br label %for2.preheader for2.preheader: %i30 = phi i64 [ 1, %entry ], [ %i.next31, %for1.inc14 ] br label %for2 for2: %j = phi i64 [ %i.next, %for2 ], [ 1, %for2.preheader ] %j.prev = add nsw i64 %j, -1 %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %j.prev, i64 %i30 %lv1 = load i32, i32* %arrayidx5 %arrayidx9 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @B, i64 0, i64 %j, i64 %i30 %lv2 = load i32, i32* %arrayidx9 %add = add nsw i32 %lv1, %lv2 %arrayidx13 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %j, i64 %i30 store i32 %add, i32* %arrayidx13 %i.next = add nuw nsw i64 %j, 1 %exitcond = icmp eq i64 %j, 99 br i1 %exitcond, label %for1.inc14, label %for2 for1.inc14: %i.next31 = add nuw nsw i64 %i30, 1 %exitcond33 = icmp eq i64 %i30, 99 br i1 %exitcond33, label %for.end16, label %for2.preheader for.end16: ret void } ;; ---------------------------------------Test case 02--------------------------------- ;; Check loop interchange profitability model. ;; This tests profitability model when operands of getelementpointer and not exactly the induction variable but some ;; arithmetic operation on them. ;; for(int i=1;i