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 -S %s | FileCheck %s
6 @wdtdr = external dso_local global [5 x [5 x double]], align 16
11 ; CHECK-NEXT: br label [[INNER_HEADER_PREHEADER:%.*]]
12 ; CHECK: outer.header.preheader:
13 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
14 ; CHECK: outer.header:
15 ; CHECK-NEXT: [[OUTER_IDX:%.*]] = phi i64 [ [[OUTER_IDX_INC:%.*]], [[OUTER_LATCH:%.*]] ], [ 0, [[OUTER_HEADER_PREHEADER:%.*]] ]
16 ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds [5 x [5 x double]], ptr @wdtdr, i64 0, i64 0, i64 [[OUTER_IDX]]
17 ; CHECK-NEXT: br label [[INNER_HEADER_SPLIT:%.*]]
18 ; CHECK: inner.header.preheader:
19 ; CHECK-NEXT: br label [[INNER_HEADER:%.*]]
20 ; CHECK: inner.header:
21 ; CHECK-NEXT: [[INNER_IDX:%.*]] = phi i64 [ [[TMP3:%.*]], [[INNER_LATCH_SPLIT:%.*]] ], [ 0, [[INNER_HEADER_PREHEADER]] ]
22 ; CHECK-NEXT: br label [[OUTER_HEADER_PREHEADER]]
23 ; CHECK: inner.header.split:
24 ; CHECK-NEXT: [[TMP0:%.*]] = load double, ptr [[ARRAYIDX8]], align 8
25 ; CHECK-NEXT: store double undef, ptr [[ARRAYIDX8]], align 8
26 ; CHECK-NEXT: br label [[INNER_LATCH:%.*]]
28 ; CHECK-NEXT: [[INNER_IDX_INC:%.*]] = add nsw i64 [[INNER_IDX]], 1
29 ; CHECK-NEXT: br label [[INNER_EXIT:%.*]]
30 ; CHECK: inner.latch.split:
31 ; CHECK-NEXT: [[TMP1:%.*]] = phi i64 [ [[OUTER_V:%.*]], [[OUTER_LATCH]] ]
32 ; CHECK-NEXT: [[TMP2:%.*]] = phi i64 [ [[OUTER_IDX_INC]], [[OUTER_LATCH]] ]
33 ; CHECK-NEXT: [[TMP3]] = add nsw i64 [[INNER_IDX]], 1
34 ; CHECK-NEXT: br i1 false, label [[INNER_HEADER]], label [[OUTER_EXIT:%.*]]
36 ; CHECK-NEXT: [[OUTER_V]] = add nsw i64 [[OUTER_IDX]], 1
37 ; CHECK-NEXT: br label [[OUTER_LATCH]]
39 ; CHECK-NEXT: [[OUTER_IDX_INC]] = add nsw i64 [[OUTER_IDX]], 1
40 ; CHECK-NEXT: br i1 false, label [[OUTER_HEADER]], label [[INNER_LATCH_SPLIT]]
42 ; CHECK-NEXT: [[EXIT1_LCSSA:%.*]] = phi i64 [ [[TMP1]], [[INNER_LATCH_SPLIT]] ]
43 ; CHECK-NEXT: [[EXIT2_LCSSA:%.*]] = phi i64 [ [[TMP2]], [[INNER_LATCH_SPLIT]] ]
44 ; CHECK-NEXT: ret void
47 br label %outer.header
49 outer.header: ; preds = %for.inc27, %entry
50 %outer.idx = phi i64 [ 0, %entry ], [ %outer.idx.inc, %outer.latch ]
51 %arrayidx8 = getelementptr inbounds [5 x [5 x double]], ptr @wdtdr, i64 0, i64 0, i64 %outer.idx
52 br label %inner.header
54 inner.header: ; preds = %for.inc, %for.body
55 %inner.idx = phi i64 [ 0, %outer.header ], [ %inner.idx.inc, %inner.latch]
56 %0 = load double, ptr %arrayidx8, align 8
57 store double undef, ptr %arrayidx8, align 8
60 inner.latch: ; preds = %for.body6
61 %inner.idx.inc = add nsw i64 %inner.idx, 1
62 br i1 undef, label %inner.header, label %inner.exit
64 inner.exit: ; preds = %for.inc
65 %outer.v = add nsw i64 %outer.idx, 1
68 outer.latch: ; preds = %for.end
69 %outer.idx.inc = add nsw i64 %outer.idx, 1
70 br i1 undef, label %outer.header, label %outer.exit
72 outer.exit: ; preds = %for.inc27
73 %exit1.lcssa = phi i64 [ %outer.v, %outer.latch ]
74 %exit2.lcssa = phi i64 [ %outer.idx.inc, %outer.latch ]
78 define void @test2(i1 %cond) {
79 ; CHECK-LABEL: @test2(
81 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[INNER_HEADER_PREHEADER:%.*]], label [[OUTER_EXIT:%.*]]
82 ; CHECK: outer.header.preheader:
83 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
84 ; CHECK: outer.header:
85 ; CHECK-NEXT: [[OUTER_IDX:%.*]] = phi i64 [ [[OUTER_IDX_INC:%.*]], [[OUTER_LATCH:%.*]] ], [ 0, [[OUTER_HEADER_PREHEADER:%.*]] ]
86 ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds [5 x [5 x double]], ptr @wdtdr, i64 0, i64 0, i64 [[OUTER_IDX]]
87 ; CHECK-NEXT: br label [[INNER_HEADER_SPLIT:%.*]]
88 ; CHECK: inner.header.preheader:
89 ; CHECK-NEXT: br label [[INNER_HEADER:%.*]]
90 ; CHECK: inner.header:
91 ; CHECK-NEXT: [[INNER_IDX:%.*]] = phi i64 [ [[TMP3:%.*]], [[INNER_LATCH_SPLIT:%.*]] ], [ 0, [[INNER_HEADER_PREHEADER]] ]
92 ; CHECK-NEXT: br label [[OUTER_HEADER_PREHEADER]]
93 ; CHECK: inner.header.split:
94 ; CHECK-NEXT: [[TMP0:%.*]] = load double, ptr [[ARRAYIDX8]], align 8
95 ; CHECK-NEXT: store double undef, ptr [[ARRAYIDX8]], align 8
96 ; CHECK-NEXT: br label [[INNER_LATCH:%.*]]
98 ; CHECK-NEXT: [[INNER_IDX_INC:%.*]] = add nsw i64 [[INNER_IDX]], 1
99 ; CHECK-NEXT: br label [[INNER_EXIT:%.*]]
100 ; CHECK: inner.latch.split:
101 ; CHECK-NEXT: [[TMP1:%.*]] = phi i64 [ [[OUTER_IDX_INC]], [[OUTER_LATCH]] ]
102 ; CHECK-NEXT: [[TMP2:%.*]] = phi i64 [ [[OUTER_V:%.*]], [[OUTER_LATCH]] ]
103 ; CHECK-NEXT: [[TMP3]] = add nsw i64 [[INNER_IDX]], 1
104 ; CHECK-NEXT: br i1 false, label [[INNER_HEADER]], label [[OUTER_EXIT_LOOPEXIT:%.*]]
106 ; CHECK-NEXT: [[OUTER_V]] = add nsw i64 [[OUTER_IDX]], 1
107 ; CHECK-NEXT: br label [[OUTER_LATCH]]
108 ; CHECK: outer.latch:
109 ; CHECK-NEXT: [[OUTER_IDX_INC]] = add nsw i64 [[OUTER_IDX]], 1
110 ; CHECK-NEXT: br i1 false, label [[OUTER_HEADER]], label [[INNER_LATCH_SPLIT]]
111 ; CHECK: outer.exit.loopexit:
112 ; CHECK-NEXT: [[OUTER_IDX_INC_LCSSA:%.*]] = phi i64 [ [[TMP1]], [[INNER_LATCH_SPLIT]] ]
113 ; CHECK-NEXT: [[OUTER_V_LCSSA:%.*]] = phi i64 [ [[TMP2]], [[INNER_LATCH_SPLIT]] ]
114 ; CHECK-NEXT: br label [[OUTER_EXIT]]
116 ; CHECK-NEXT: [[EXIT1_LCSSA:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[OUTER_V_LCSSA]], [[OUTER_EXIT_LOOPEXIT]] ]
117 ; CHECK-NEXT: [[EXIT2_LCSSA:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[OUTER_IDX_INC_LCSSA]], [[OUTER_EXIT_LOOPEXIT]] ]
118 ; CHECK-NEXT: ret void
121 br i1 %cond, label %outer.header, label %outer.exit
123 outer.header: ; preds = %for.inc27, %entry
124 %outer.idx = phi i64 [ 0, %entry ], [ %outer.idx.inc, %outer.latch ]
125 %arrayidx8 = getelementptr inbounds [5 x [5 x double]], ptr @wdtdr, i64 0, i64 0, i64 %outer.idx
126 br label %inner.header
128 inner.header: ; preds = %for.inc, %for.body
129 %inner.idx = phi i64 [ 0, %outer.header ], [ %inner.idx.inc, %inner.latch]
130 %0 = load double, ptr %arrayidx8, align 8
131 store double undef, ptr %arrayidx8, align 8
132 br label %inner.latch
134 inner.latch: ; preds = %for.body6
135 %inner.idx.inc = add nsw i64 %inner.idx , 1
136 br i1 undef, label %inner.header, label %inner.exit
138 inner.exit: ; preds = %for.inc
139 %outer.v = add nsw i64 %outer.idx, 1
140 br label %outer.latch
142 outer.latch: ; preds = %for.end
143 %outer.idx.inc = add nsw i64 %outer.idx, 1
144 br i1 undef, label %outer.header, label %outer.exit
146 outer.exit: ; preds = %for.inc27
147 %exit1.lcssa = phi i64 [ 0, %entry ], [ %outer.v, %outer.latch ]
148 %exit2.lcssa = phi i64 [ 0, %entry ], [ %outer.idx.inc, %outer.latch ]