|
| 1 | +; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -verify-dom-info -verify-loop-info \ |
| 2 | +; RUN: -S -debug 2>&1 | FileCheck %s |
| 3 | + |
| 4 | +@bb = global [1024 x [128 x float]] zeroinitializer, align 4 |
| 5 | +@aa = global [1024 x [128 x float]] zeroinitializer, align 4 |
| 6 | +@cc = global [1024 x [128 x float]] zeroinitializer, align 4 |
| 7 | + |
| 8 | + |
| 9 | +;; for (int j = 1; j < M; j++) |
| 10 | +;; for (int i = 1; i < N; i++) { |
| 11 | +;; aa[1][j-1] += bb[i][j]; |
| 12 | +;; cc[i][j] = aa[1][j]; |
| 13 | +;; } |
| 14 | + |
| 15 | +; CHECK: Loops interchanged. |
| 16 | + |
| 17 | +define void @pr54176() { |
| 18 | +entry: |
| 19 | + br label %for.cond1.preheader |
| 20 | + |
| 21 | +; Loop: |
| 22 | +for.cond1.preheader: ; preds = %entry, %for.cond.cleanup3 |
| 23 | + %indvars.iv28 = phi i64 [ 1, %entry ], [ %indvars.iv.next29, %for.cond.cleanup3 ] |
| 24 | + %0 = add nsw i64 %indvars.iv28, -1 |
| 25 | + %arrayidx8 = getelementptr inbounds [1024 x [128 x float]], ptr @aa, i64 0, i64 1, i64 %0 |
| 26 | + %arrayidx10 = getelementptr inbounds [1024 x [128 x float]], ptr @aa, i64 0, i64 1, i64 %indvars.iv28 |
| 27 | + br label %for.body4 |
| 28 | + |
| 29 | +for.cond.cleanup3: ; preds = %for.body4 |
| 30 | + %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1 |
| 31 | + %exitcond31 = icmp ne i64 %indvars.iv.next29, 128 |
| 32 | + br i1 %exitcond31, label %for.cond1.preheader, label %for.cond.cleanup |
| 33 | + |
| 34 | +for.body4: ; preds = %for.cond1.preheader, %for.body4 |
| 35 | + %indvars.iv = phi i64 [ 1, %for.cond1.preheader ], [ %indvars.iv.next, %for.body4 ] |
| 36 | + %arrayidx6 = getelementptr inbounds [1024 x [128 x float]], ptr @bb, i64 0, i64 %indvars.iv, i64 %indvars.iv28 |
| 37 | + %1 = load float, ptr %arrayidx6, align 4 |
| 38 | + %2 = load float, ptr %arrayidx8, align 4 |
| 39 | + %add = fadd float %1, %2 |
| 40 | + store float %add, ptr %arrayidx8, align 4 |
| 41 | + %3 = load float, ptr %arrayidx10, align 4 |
| 42 | + %arrayidx14 = getelementptr inbounds [1024 x [128 x float]], ptr @cc, i64 0, i64 %indvars.iv, i64 %indvars.iv28 |
| 43 | + store float %3, ptr %arrayidx14, align 4 |
| 44 | + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 |
| 45 | + %exitcond = icmp ne i64 %indvars.iv.next, 1024 |
| 46 | + br i1 %exitcond, label %for.body4, label %for.cond.cleanup3 |
| 47 | + |
| 48 | +; Exit blocks |
| 49 | +for.cond.cleanup: ; preds = %for.cond.cleanup3 |
| 50 | + ret void |
| 51 | +} |
0 commit comments