|
| 1 | +; REQUIRES: asserts |
| 2 | +; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -verify-dom-info -verify-loop-info \ |
| 3 | +; RUN: -S -debug 2>&1 | FileCheck %s |
| 4 | + |
| 5 | +;; Test that a confused dependency in loop should prevent interchange in |
| 6 | +;; loops i and j. |
| 7 | +;; |
| 8 | +;; void test_deps() { |
| 9 | +;; for (int i = 0; i <= 3; i++) |
| 10 | +;; for (int j = 0; j <= 3; j++) { |
| 11 | +;; *f ^= 0x1000; |
| 12 | +;; c[j][i] = *f; |
| 13 | +;; } |
| 14 | +;; } |
| 15 | + |
| 16 | +; CHECK: Loops interchanged. |
| 17 | + |
| 18 | +@a = global i32 0, align 4 |
| 19 | +@f = global ptr @a, align 8 |
| 20 | +@c = global [4 x [4 x i32]] zeroinitializer, align 8 |
| 21 | + |
| 22 | +define void @test_deps() { |
| 23 | +entry: |
| 24 | + %0 = load ptr, ptr @f, align 8 |
| 25 | + br label %for.cond1.preheader |
| 26 | + |
| 27 | +; Loop: |
| 28 | +for.cond1.preheader: ; preds = %entry, %for.cond.cleanup3 |
| 29 | + %indvars.iv16 = phi i64 [ 0, %entry ], [ %indvars.iv.next17, %for.cond.cleanup3 ] |
| 30 | + br label %for.body4 |
| 31 | + |
| 32 | +for.cond.cleanup3: ; preds = %for.body4 |
| 33 | + %indvars.iv.next17 = add nuw nsw i64 %indvars.iv16, 1 |
| 34 | + %exitcond18 = icmp ne i64 %indvars.iv.next17, 4 |
| 35 | + br i1 %exitcond18, label %for.cond1.preheader, label %for.cond.cleanup |
| 36 | + |
| 37 | +for.body4: ; preds = %for.cond1.preheader, %for.body4 |
| 38 | + %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.body4 ] |
| 39 | + %1 = load i32, ptr %0, align 4 |
| 40 | + %xor = xor i32 %1, 4096 |
| 41 | + store i32 %xor, ptr %0, align 4 |
| 42 | + %arrayidx6 = getelementptr inbounds [4 x [4 x i32]], ptr @c, i64 0, i64 %indvars.iv, i64 %indvars.iv16 |
| 43 | + store i32 %xor, ptr %arrayidx6, align 4 |
| 44 | + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 |
| 45 | + %exitcond = icmp ne i64 %indvars.iv.next, 4 |
| 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