| 1 |
; REQUIRES: asserts |
| 2 |
; RUN: opt < %s -passes=loop-interchange -verify-dom-info -verify-loop-info -S -debug 2>&1 | FileCheck %s |
| 3 |
|
| 4 |
@A = common global [100 x [100 x i64]] zeroinitializer |
| 5 |
@N = dso_local local_unnamed_addr global i64 100, align 8 |
| 6 |
|
| 7 |
; for(int i=0;i<100;i++) |
| 8 |
; for(int j=0;j<i;j++) |
| 9 |
; A[j][i] = A[j][i]+k; |
| 10 |
; |
| 11 |
; Inner loop induction variable exit condition depends on the |
| 12 |
; outer loop induction variable, i.e., triangular loops. |
| 13 |
; |
| 14 |
; CHECK: Loop structure not understood by pass |
| 15 |
; CHECK: Cannot prove legality, not interchanging loops 'for1.header' and 'for2' |
| 16 |
; |
| 17 |
define void @interchange_01(i64 %k) { |
| 18 |
entry: |
| 19 |
br label %for1.header |
| 20 |
|
| 21 |
for1.header: |
| 22 |
%i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ] |
| 23 |
br label %for2 |
| 24 |
|
| 25 |
for2: |
| 26 |
%j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ] |
| 27 |
%arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i |
| 28 |
%lv = load i64, ptr %arrayidx5 |
| 29 |
%add = add nsw i64 %lv, %k |
| 30 |
store i64 %add, ptr %arrayidx5 |
| 31 |
%j.next = add nuw nsw i64 %j, 1 |
| 32 |
%exitcond = icmp eq i64 %j, %i |
| 33 |
br i1 %exitcond, label %for1.inc10, label %for2 |
| 34 |
|
| 35 |
for1.inc10: |
| 36 |
%i.next = add nuw nsw i64 %i, 1 |
| 37 |
%exitcond26 = icmp eq i64 %i, 99 |
| 38 |
br i1 %exitcond26, label %for.end12, label %for1.header |
| 39 |
|
| 40 |
for.end12: |
| 41 |
ret void |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
; for(int i=0;i<100;i++) |
| 46 |
; for(int j=0;j+i<100;j++) |
| 47 |
; A[j][i] = A[j][i]+k; |
| 48 |
; |
| 49 |
; Inner loop induction variable exit condition depends on the |
| 50 |
; outer loop induction variable, i.e., triangular loops. |
| 51 |
; |
| 52 |
; CHECK: Loop structure not understood by pass |
| 53 |
; CHECK: Cannot prove legality, not interchanging loops 'for1.header' and 'for2' |
| 54 |
; |
| 55 |
define void @interchange_02(i64 %k) { |
| 56 |
entry: |
| 57 |
br label %for1.header |
| 58 |
|
| 59 |
for1.header: |
| 60 |
%i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ] |
| 61 |
br label %for2 |
| 62 |
|
| 63 |
for2: |
| 64 |
%j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ] |
| 65 |
%arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i |
| 66 |
%lv = load i64, ptr %arrayidx5 |
| 67 |
%add = add nsw i64 %lv, %k |
| 68 |
store i64 %add, ptr %arrayidx5 |
| 69 |
%0 = add nuw nsw i64 %j, %i |
| 70 |
%j.next = add nuw nsw i64 %j, 1 |
| 71 |
%exitcond = icmp eq i64 %0, 100 |
| 72 |
br i1 %exitcond, label %for1.inc10, label %for2 |
| 73 |
|
| 74 |
for1.inc10: |
| 75 |
%i.next = add nuw nsw i64 %i, 1 |
| 76 |
%exitcond26 = icmp eq i64 %i, 99 |
| 77 |
br i1 %exitcond26, label %for.end12, label %for1.header |
| 78 |
|
| 79 |
for.end12: |
| 80 |
ret void |
| 81 |
} |
| 82 |
|
| 83 |
; for(int i=0;i<100;i++) |
| 84 |
; for(int j=0;i>j;j++) |
| 85 |
; A[j][i] = A[j][i]+k; |
| 86 |
; |
| 87 |
; Inner loop induction variable exit condition depends on the |
| 88 |
; outer loop induction variable, i.e., triangular loops. |
| 89 |
; CHECK: Loop structure not understood by pass |
| 90 |
; CHECK: Cannot prove legality, not interchanging loops 'for1.header' and 'for2' |
| 91 |
; |
| 92 |
define void @interchange_03(i64 %k) { |
| 93 |
entry: |
| 94 |
br label %for1.header |
| 95 |
|
| 96 |
for1.header: |
| 97 |
%i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ] |
| 98 |
br label %for2 |
| 99 |
|
| 100 |
for2: |
| 101 |
%j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ] |
| 102 |
%arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i |
| 103 |
%lv = load i64, ptr %arrayidx5 |
| 104 |
%add = add nsw i64 %lv, %k |
| 105 |
store i64 %add, ptr %arrayidx5 |
| 106 |
%j.next = add nuw nsw i64 %j, 1 |
| 107 |
%exitcond = icmp ne i64 %i, %j |
| 108 |
br i1 %exitcond, label %for2, label %for1.inc10 |
| 109 |
|
| 110 |
for1.inc10: |
| 111 |
%i.next = add nuw nsw i64 %i, 1 |
| 112 |
%exitcond26 = icmp eq i64 %i, 99 |
| 113 |
br i1 %exitcond26, label %for.end12, label %for1.header |
| 114 |
|
| 115 |
for.end12: |
| 116 |
ret void |
| 117 |
} |