1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -S
3 ; RUN: FileCheck --input-file=%t %s
5 @b = external dso_local global [5 x i32], align 16
7 ;; Not profitable to interchange, because the access is invariant to j loop.
9 ;; for(int i=0;i<4;i++) {
10 ;; for(int j=1;j<4;j++) {
16 ; CHECK-NEXT: Pass: loop-interchange
17 ; CHECK-NEXT: Name: InterchangeNotProfitable
18 ; CHECK-NEXT: Function: test1
20 ; CHECK-NEXT: - String: Interchanging loops is not considered to improve cache locality nor vectorization.
22 define void @test1() {
26 for.body: ; preds = %for.inc3, %entry
27 %inc41 = phi i32 [ %inc4, %for.inc3 ], [ undef, %entry ]
30 for.body2: ; preds = %for.inc, %for.body
31 %lsr.iv = phi i32 [ %lsr.iv.next, %for.inc ], [ 1, %for.body ]
34 for.inc: ; preds = %for.body2
35 %idxprom = sext i32 %inc41 to i64
36 %arrayidx = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 %idxprom
37 %0 = load i32, ptr %arrayidx, align 4
38 store i32 undef, ptr %arrayidx, align 4
39 %cmp = icmp slt i32 %lsr.iv, 4
40 %lsr.iv.next = add nuw nsw i32 %lsr.iv, 1
41 br i1 %cmp, label %for.body2, label %for.cond1.for.end_crit_edge
43 for.cond1.for.end_crit_edge: ; preds = %for.inc
46 for.inc3: ; preds = %for.cond1.for.end_crit_edge
47 %inc4 = add nsw i32 %inc41, 1
48 br i1 false, label %for.body, label %for.cond.for.end5_crit_edge
50 for.cond.for.end5_crit_edge: ; preds = %for.inc3
56 ; CHECK-NEXT: Pass: loop-interchange
57 ; CHECK-NEXT: Name: InterchangeNotProfitable
58 ; CHECK-NEXT: Function: test2
60 ; CHECK-NEXT: - String: Interchanging loops is not considered to improve cache locality nor vectorization.
62 define void @test2() {
66 for.body: ; preds = %for.inc3, %entry
67 %inc41 = phi i32 [ %inc4, %for.inc3 ], [ undef, %entry ]
70 for.body2: ; preds = %for.inc, %for.body
71 %lsr.iv = phi i32 [ %lsr.iv.next, %for.inc ], [ 1, %for.body ]
74 for.inc: ; preds = %for.body2
75 %idxprom = sext i32 %inc41 to i64
76 %arrayidx = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 %idxprom
77 %0 = load i32, ptr %arrayidx, align 4
78 %cmp = icmp slt i32 %lsr.iv, 4
79 %cmp.zext = zext i1 %cmp to i32
80 store i32 %cmp.zext, ptr %arrayidx, align 4
81 %lsr.iv.next = add nuw nsw i32 %lsr.iv, 1
82 br i1 %cmp, label %for.body2, label %for.cond1.for.end_crit_edge
84 for.cond1.for.end_crit_edge: ; preds = %for.inc
87 for.inc3: ; preds = %for.cond1.for.end_crit_edge
88 %inc4 = add nsw i32 %inc41, 1
89 br i1 false, label %for.body, label %for.cond.for.end5_crit_edge
91 for.cond.for.end5_crit_edge: ; preds = %for.inc3