1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-interchange -cache-line-size=64 -verify-loop-lcssa -verify-dom-info -S %s | FileCheck %s
4 @b = external dso_local global [5 x i32], align 16
9 ; CHECK-NEXT: br label [[FOR_BODY2_PREHEADER:%.*]]
10 ; CHECK: for.body.preheader:
11 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
13 ; CHECK-NEXT: [[INC41:%.*]] = phi i32 [ [[INC4:%.*]], [[FOR_INC3:%.*]] ], [ undef, [[FOR_BODY_PREHEADER:%.*]] ]
14 ; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[INC41]] to i64
15 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 [[IDXPROM]]
16 ; CHECK-NEXT: br label [[FOR_INC:%.*]]
17 ; CHECK: for.body2.preheader:
18 ; CHECK-NEXT: br label [[FOR_BODY2:%.*]]
20 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i32 [ [[TMP1:%.*]], [[FOR_INC_SPLIT:%.*]] ], [ 1, [[FOR_BODY2_PREHEADER]] ]
21 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER]]
23 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
24 ; CHECK-NEXT: store i32 undef, ptr [[ARRAYIDX]], align 4
25 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[LSR_IV]], 4
26 ; CHECK-NEXT: [[LSR_IV_NEXT:%.*]] = add nuw nsw i32 [[LSR_IV]], 1
27 ; CHECK-NEXT: br label [[FOR_COND1_FOR_END_CRIT_EDGE:%.*]]
28 ; CHECK: for.inc.split:
29 ; CHECK-NEXT: [[TMP1]] = add nuw nsw i32 [[LSR_IV]], 1
30 ; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[LSR_IV]], 4
31 ; CHECK-NEXT: br i1 [[TMP2]], label [[FOR_BODY2]], label [[FOR_COND_FOR_END5_CRIT_EDGE:%.*]]
32 ; CHECK: for.cond1.for.end_crit_edge:
33 ; CHECK-NEXT: br label [[FOR_INC3]]
35 ; CHECK-NEXT: [[INC4]] = add nsw i32 [[INC41]], 1
36 ; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[FOR_INC_SPLIT]]
37 ; CHECK: for.cond.for.end5_crit_edge:
38 ; CHECK-NEXT: ret void
43 for.body: ; preds = %for.inc3, %entry
44 %inc41 = phi i32 [ %inc4, %for.inc3 ], [ undef, %entry ]
47 for.body2: ; preds = %for.inc, %for.body
48 %lsr.iv = phi i32 [ %lsr.iv.next, %for.inc ], [ 1, %for.body ]
51 for.inc: ; preds = %for.body2
52 %idxprom = sext i32 %inc41 to i64
53 %arrayidx = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 %idxprom
54 %0 = load i32, ptr %arrayidx, align 4
55 store i32 undef, ptr %arrayidx, align 4
56 %cmp = icmp slt i32 %lsr.iv, 4
57 %lsr.iv.next = add nuw nsw i32 %lsr.iv, 1
58 br i1 %cmp, label %for.body2, label %for.cond1.for.end_crit_edge
60 for.cond1.for.end_crit_edge: ; preds = %for.inc
63 for.inc3: ; preds = %for.cond1.for.end_crit_edge
64 %inc4 = add nsw i32 %inc41, 1
65 br i1 undef, label %for.body, label %for.cond.for.end5_crit_edge
67 for.cond.for.end5_crit_edge: ; preds = %for.inc3
71 define void @test2() {
72 ; CHECK-LABEL: @test2(
74 ; CHECK-NEXT: br label [[FOR_BODY2_PREHEADER:%.*]]
75 ; CHECK: for.body.preheader:
76 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
78 ; CHECK-NEXT: [[INC41:%.*]] = phi i32 [ [[INC4:%.*]], [[FOR_INC3:%.*]] ], [ undef, [[FOR_BODY_PREHEADER:%.*]] ]
79 ; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[INC41]] to i64
80 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 [[IDXPROM]]
81 ; CHECK-NEXT: br label [[FOR_INC:%.*]]
82 ; CHECK: for.body2.preheader:
83 ; CHECK-NEXT: br label [[FOR_BODY2:%.*]]
85 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i32 [ [[TMP1:%.*]], [[FOR_INC_SPLIT:%.*]] ], [ 1, [[FOR_BODY2_PREHEADER]] ]
86 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER]]
88 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
89 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[LSR_IV]], 4
90 ; CHECK-NEXT: [[CMP_ZEXT:%.*]] = zext i1 [[CMP]] to i32
91 ; CHECK-NEXT: store i32 [[CMP_ZEXT]], ptr [[ARRAYIDX]], align 4
92 ; CHECK-NEXT: [[LSR_IV_NEXT:%.*]] = add nuw nsw i32 [[LSR_IV]], 1
93 ; CHECK-NEXT: br label [[FOR_COND1_FOR_END_CRIT_EDGE:%.*]]
94 ; CHECK: for.inc.split:
95 ; CHECK-NEXT: [[TMP1]] = add nuw nsw i32 [[LSR_IV]], 1
96 ; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[LSR_IV]], 4
97 ; CHECK-NEXT: br i1 [[TMP2]], label [[FOR_BODY2]], label [[FOR_COND_FOR_END5_CRIT_EDGE:%.*]]
98 ; CHECK: for.cond1.for.end_crit_edge:
99 ; CHECK-NEXT: br label [[FOR_INC3]]
101 ; CHECK-NEXT: [[INC4]] = add nsw i32 [[INC41]], 1
102 ; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[FOR_INC_SPLIT]]
103 ; CHECK: for.cond.for.end5_crit_edge:
104 ; CHECK-NEXT: ret void
109 for.body: ; preds = %for.inc3, %entry
110 %inc41 = phi i32 [ %inc4, %for.inc3 ], [ undef, %entry ]
113 for.body2: ; preds = %for.inc, %for.body
114 %lsr.iv = phi i32 [ %lsr.iv.next, %for.inc ], [ 1, %for.body ]
117 for.inc: ; preds = %for.body2
118 %idxprom = sext i32 %inc41 to i64
119 %arrayidx = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 %idxprom
120 %0 = load i32, ptr %arrayidx, align 4
121 %cmp = icmp slt i32 %lsr.iv, 4
122 %cmp.zext = zext i1 %cmp to i32
123 store i32 %cmp.zext, ptr %arrayidx, align 4
124 %lsr.iv.next = add nuw nsw i32 %lsr.iv, 1
125 br i1 %cmp, label %for.body2, label %for.cond1.for.end_crit_edge
127 for.cond1.for.end_crit_edge: ; preds = %for.inc
130 for.inc3: ; preds = %for.cond1.for.end_crit_edge
131 %inc4 = add nsw i32 %inc41, 1
132 br i1 undef, label %for.body, label %for.cond.for.end5_crit_edge
134 for.cond.for.end5_crit_edge: ; preds = %for.inc3