77 lines · plain
1; RUN: opt < %s -passes=loop-interchange -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t \2; RUN: -verify-dom-info -verify-loop-info -verify-loop-lcssa3; RUN: FileCheck --input-file=%t %s4 5;; The original code:6;;7;; #define N 48;; int a[N*N][N*N][N*N];9;; void f() {10;; for (int i = 0; i < N; i++)11;; for (int j = 1; j < 2*N; j++)12;; for (int k = 1; k < 2*N; k++)13;; a[2*i][k+1][j-1] -= a[i+N-1][k][j];14;; }15;;16;; The entry of the direction vector for the outermost loop is `DVEntry::LE`.17;; We need to treat this as `*`, not `<`. See issue #123920 for details.18;; In conclusion, we must not interchange the loops.19 20; CHECK: --- !Missed21; CHECK-NEXT: Pass: loop-interchange22; CHECK-NEXT: Name: Dependence23; CHECK-NEXT: Function: f24; CHECK-NEXT: Args:25; CHECK-NEXT: - String: All loops have dependencies in all directions.26; CHECK-NEXT: ...27 28 29@a = dso_local global [16 x [16 x [16 x i32]]] zeroinitializer, align 430 31define dso_local void @f() {32entry:33 br label %for.cond1.preheader34 35for.cond1.preheader:36 %i.039 = phi i32 [ 0, %entry ], [ %inc26, %for.cond.cleanup3 ]37 %sub = add nuw nsw i32 %i.039, 338 %idxprom = zext nneg i32 %sub to i6439 %mul = shl nuw nsw i32 %i.039, 140 %idxprom13 = zext nneg i32 %mul to i6441 br label %for.cond5.preheader42 43for.cond.cleanup:44 ret void45 46for.cond5.preheader:47 %j.038 = phi i32 [ 1, %for.cond1.preheader ], [ %inc23, %for.cond.cleanup7 ]48 %idxprom11 = zext nneg i32 %j.038 to i6449 %sub18 = add nsw i32 %j.038, -150 %idxprom19 = sext i32 %sub18 to i6451 br label %for.body852 53for.cond.cleanup3:54 %inc26 = add nuw nsw i32 %i.039, 155 %cmp = icmp samesign ult i32 %i.039, 356 br i1 %cmp, label %for.cond1.preheader, label %for.cond.cleanup57 58for.cond.cleanup7:59 %inc23 = add nuw nsw i32 %j.038, 160 %cmp2 = icmp samesign ult i32 %j.038, 761 br i1 %cmp2, label %for.cond5.preheader, label %for.cond.cleanup362 63for.body8:64 %k.037 = phi i32 [ 1, %for.cond5.preheader ], [ %add15, %for.body8 ]65 %idxprom9 = zext nneg i32 %k.037 to i6466 %arrayidx12 = getelementptr inbounds nuw [16 x [16 x [16 x i32]]], ptr @a, i64 0, i64 %idxprom, i64 %idxprom9, i64 %idxprom1167 %0 = load i32, ptr %arrayidx12, align 468 %add15 = add nuw nsw i32 %k.037, 169 %idxprom16 = zext nneg i32 %add15 to i6470 %arrayidx20 = getelementptr inbounds [16 x [16 x [16 x i32]]], ptr @a, i64 0, i64 %idxprom13, i64 %idxprom16, i64 %idxprom1971 %1 = load i32, ptr %arrayidx20, align 472 %sub21 = sub nsw i32 %1, %073 store i32 %sub21, ptr %arrayidx20, align 474 %cmp6 = icmp samesign ult i32 %k.037, 775 br i1 %cmp6, label %for.body8, label %for.cond.cleanup776}77