| 1 |
; RUN: opt < %s -passes=loop-interchange -pass-remarks-output=%t -disable-output -loop-interchange-profitabilities=ignore -S |
| 2 |
; RUN: FileCheck --input-file=%t %s |
| 3 |
|
| 4 |
; There should be no reason to interchange this, unless it is forced. |
| 5 |
; |
| 6 |
; for (int i = 0; i<1024; i++) |
| 7 |
; for (int j = 0; j<1024; j++) |
| 8 |
; A[i][j] = 42; |
| 9 |
; |
| 10 |
; CHECK: --- !Passed |
| 11 |
; CHECK-NEXT: Pass: loop-interchange |
| 12 |
; CHECK-NEXT: Name: Interchanged |
| 13 |
; CHECK-NEXT: Function: f |
| 14 |
; CHECK-NEXT: Args: |
| 15 |
; CHECK-NEXT: - String: Loop interchanged with enclosing loop. |
| 16 |
; CHECK-NEXT: ... |
| 17 |
|
| 18 |
@A = dso_local local_unnamed_addr global [1024 x [1024 x i32]] zeroinitializer, align 4 |
| 19 |
|
| 20 |
define dso_local void @f() local_unnamed_addr #0 { |
| 21 |
entry: |
| 22 |
br label %outer.header |
| 23 |
|
| 24 |
outer.header: |
| 25 |
%i = phi i64 [ 0, %entry ], [ %i.next, %inner.header ] |
| 26 |
br label %inner.body |
| 27 |
|
| 28 |
inner.header: |
| 29 |
%i.next = add nuw nsw i64 %i, 1 |
| 30 |
%exitcond20.not = icmp eq i64 %i.next, 1024 |
| 31 |
br i1 %exitcond20.not, label %exit, label %outer.header |
| 32 |
|
| 33 |
inner.body: |
| 34 |
%j = phi i64 [ 0, %outer.header ], [ %j.next, %inner.body ] |
| 35 |
%arrayidx6 = getelementptr inbounds nuw [1024 x [1024 x i32]], ptr @A, i64 0, i64 %i, i64 %j |
| 36 |
store i32 42, ptr %arrayidx6, align 4 |
| 37 |
%j.next = add nuw nsw i64 %j, 1 |
| 38 |
%exitcond.not = icmp eq i64 %j.next, 1024 |
| 39 |
br i1 %exitcond.not, label %inner.header, label %inner.body |
| 40 |
|
| 41 |
exit: |
| 42 |
ret void |
| 43 |
} |