1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='loop(simple-loop-unswitch)' -S %s | FileCheck %s
4 declare void @some_func()
6 define i32 @need_freeze_of_individual_or_conditions1(i1 %cond1, i1 %cond2, i1 %cond3, i1 %cond4) {
7 ; CHECK-LABEL: @need_freeze_of_individual_or_conditions1(
9 ; CHECK-NEXT: [[COND4_FR:%.*]] = freeze i1 [[COND4:%.*]]
10 ; CHECK-NEXT: [[COND1_FR:%.*]] = freeze i1 [[COND1:%.*]]
11 ; CHECK-NEXT: [[TMP0:%.*]] = and i1 [[COND4_FR]], [[COND1_FR]]
12 ; CHECK-NEXT: br i1 [[TMP0]], label [[ENTRY_SPLIT:%.*]], label [[EXIT_SPLIT:%.*]]
14 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
16 ; CHECK-NEXT: [[OR:%.*]] = or i1 [[COND2:%.*]], [[COND3:%.*]]
17 ; CHECK-NEXT: [[AND1:%.*]] = and i1 [[OR]], true
18 ; CHECK-NEXT: [[AND2:%.*]] = select i1 [[AND1]], i1 true, i1 false
19 ; CHECK-NEXT: br i1 [[AND2]], label [[LOOP_LATCH:%.*]], label [[EXIT:%.*]]
21 ; CHECK-NEXT: call void @some_func()
22 ; CHECK-NEXT: br label [[LOOP_HEADER]]
24 ; CHECK-NEXT: br label [[EXIT_SPLIT]]
26 ; CHECK-NEXT: ret i32 0
32 %or = or i1 %cond2, %cond3
33 %and1 = and i1 %or, %cond1
34 %and2 = select i1 %and1, i1 %cond4, i1 false
35 br i1 %and2, label %loop.latch, label %exit
38 call void @some_func()
45 define i32 @need_freeze_of_individual_or_conditions2(i1 noundef %cond1, i1 %cond2, i1 %cond3, i1 %cond4) {
46 ; CHECK-LABEL: @need_freeze_of_individual_or_conditions2(
48 ; CHECK-NEXT: [[COND4_FR:%.*]] = freeze i1 [[COND4:%.*]]
49 ; CHECK-NEXT: [[TMP0:%.*]] = and i1 [[COND4_FR]], [[COND1:%.*]]
50 ; CHECK-NEXT: br i1 [[TMP0]], label [[ENTRY_SPLIT:%.*]], label [[EXIT_SPLIT:%.*]]
52 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
54 ; CHECK-NEXT: [[OR:%.*]] = or i1 [[COND2:%.*]], [[COND3:%.*]]
55 ; CHECK-NEXT: [[AND1:%.*]] = and i1 [[OR]], true
56 ; CHECK-NEXT: [[AND2:%.*]] = select i1 [[AND1]], i1 true, i1 false
57 ; CHECK-NEXT: br i1 [[AND2]], label [[LOOP_LATCH:%.*]], label [[EXIT:%.*]]
59 ; CHECK-NEXT: call void @some_func()
60 ; CHECK-NEXT: br label [[LOOP_HEADER]]
62 ; CHECK-NEXT: br label [[EXIT_SPLIT]]
64 ; CHECK-NEXT: ret i32 0
70 %or = or i1 %cond2, %cond3
71 %and1 = and i1 %or, %cond1
72 %and2 = select i1 %and1, i1 %cond4, i1 false
73 br i1 %and2, label %loop.latch, label %exit
76 call void @some_func()
83 define i32 @need_freeze_of_individual_or_conditions3(i1 %cond1, i1 %cond2, i1 %cond3, i1 noundef %cond4) {
84 ; CHECK-LABEL: @need_freeze_of_individual_or_conditions3(
86 ; CHECK-NEXT: [[COND1_FR:%.*]] = freeze i1 [[COND1:%.*]]
87 ; CHECK-NEXT: [[TMP0:%.*]] = and i1 [[COND4:%.*]], [[COND1_FR]]
88 ; CHECK-NEXT: br i1 [[TMP0]], label [[ENTRY_SPLIT:%.*]], label [[EXIT_SPLIT:%.*]]
90 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
92 ; CHECK-NEXT: [[OR:%.*]] = or i1 [[COND2:%.*]], [[COND3:%.*]]
93 ; CHECK-NEXT: [[AND1:%.*]] = and i1 [[OR]], true
94 ; CHECK-NEXT: [[AND2:%.*]] = select i1 [[AND1]], i1 true, i1 false
95 ; CHECK-NEXT: br i1 [[AND2]], label [[LOOP_LATCH:%.*]], label [[EXIT:%.*]]
97 ; CHECK-NEXT: call void @some_func()
98 ; CHECK-NEXT: br label [[LOOP_HEADER]]
100 ; CHECK-NEXT: br label [[EXIT_SPLIT]]
102 ; CHECK-NEXT: ret i32 0
105 br label %loop.header
108 %or = or i1 %cond2, %cond3
109 %and1 = and i1 %or, %cond1
110 %and2 = select i1 %and1, i1 %cond4, i1 false
111 br i1 %and2, label %loop.latch, label %exit
114 call void @some_func()
115 br label %loop.header
121 define i32 @need_freeze_of_individual_and_conditions1(i1 %cond1, i1 %cond4) {
122 ; CHECK-LABEL: @need_freeze_of_individual_and_conditions1(
124 ; CHECK-NEXT: [[COND4_FR:%.*]] = freeze i1 [[COND4:%.*]]
125 ; CHECK-NEXT: [[COND1_FR:%.*]] = freeze i1 [[COND1:%.*]]
126 ; CHECK-NEXT: [[TMP0:%.*]] = or i1 [[COND4_FR]], [[COND1_FR]]
127 ; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT_SPLIT:%.*]], label [[ENTRY_SPLIT:%.*]]
128 ; CHECK: entry.split:
129 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
130 ; CHECK: loop.header:
131 ; CHECK-NEXT: [[COND_OR1:%.*]] = or i1 undef, false
132 ; CHECK-NEXT: [[COND_OR6:%.*]] = select i1 [[COND_OR1]], i1 true, i1 false
133 ; CHECK-NEXT: br i1 [[COND_OR6]], label [[EXIT:%.*]], label [[LOOP_LATCH:%.*]]
135 ; CHECK-NEXT: br label [[LOOP_HEADER]]
137 ; CHECK-NEXT: br label [[EXIT_SPLIT]]
139 ; CHECK-NEXT: ret i32 0
142 br label %loop.header
145 %cond_or1 = or i1 undef, %cond1
146 %cond_or6 = select i1 %cond_or1, i1 true, i1 %cond4
147 br i1 %cond_or6, label %exit, label %loop.latch
150 br label %loop.header
156 define i32 @need_freeze_of_individual_and_conditions2(i1 noundef %cond1, i1 %cond4) {
157 ; CHECK-LABEL: @need_freeze_of_individual_and_conditions2(
159 ; CHECK-NEXT: [[COND4_FR:%.*]] = freeze i1 [[COND4:%.*]]
160 ; CHECK-NEXT: [[TMP0:%.*]] = or i1 [[COND4_FR]], [[COND1:%.*]]
161 ; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT_SPLIT:%.*]], label [[ENTRY_SPLIT:%.*]]
162 ; CHECK: entry.split:
163 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
164 ; CHECK: loop.header:
165 ; CHECK-NEXT: [[COND_OR1:%.*]] = or i1 undef, false
166 ; CHECK-NEXT: [[COND_OR6:%.*]] = select i1 [[COND_OR1]], i1 true, i1 false
167 ; CHECK-NEXT: br i1 [[COND_OR6]], label [[EXIT:%.*]], label [[LOOP_LATCH:%.*]]
169 ; CHECK-NEXT: br label [[LOOP_HEADER]]
171 ; CHECK-NEXT: br label [[EXIT_SPLIT]]
173 ; CHECK-NEXT: ret i32 0
176 br label %loop.header
179 %cond_or1 = or i1 undef, %cond1
180 %cond_or6 = select i1 %cond_or1, i1 true, i1 %cond4
181 br i1 %cond_or6, label %exit, label %loop.latch
184 br label %loop.header
190 define i32 @need_freeze_of_individual_and_conditions3(i1 %cond1, i1 noundef %cond4) {
191 ; CHECK-LABEL: @need_freeze_of_individual_and_conditions3(
193 ; CHECK-NEXT: [[COND1_FR:%.*]] = freeze i1 [[COND1:%.*]]
194 ; CHECK-NEXT: [[TMP0:%.*]] = or i1 [[COND4:%.*]], [[COND1_FR]]
195 ; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT_SPLIT:%.*]], label [[ENTRY_SPLIT:%.*]]
196 ; CHECK: entry.split:
197 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
198 ; CHECK: loop.header:
199 ; CHECK-NEXT: [[COND_OR1:%.*]] = or i1 undef, false
200 ; CHECK-NEXT: [[COND_OR6:%.*]] = select i1 [[COND_OR1]], i1 true, i1 false
201 ; CHECK-NEXT: br i1 [[COND_OR6]], label [[EXIT:%.*]], label [[LOOP_LATCH:%.*]]
203 ; CHECK-NEXT: br label [[LOOP_HEADER]]
205 ; CHECK-NEXT: br label [[EXIT_SPLIT]]
207 ; CHECK-NEXT: ret i32 0
210 br label %loop.header
213 %cond_or1 = or i1 undef, %cond1
214 %cond_or6 = select i1 %cond_or1, i1 true, i1 %cond4
215 br i1 %cond_or6, label %exit, label %loop.latch
218 br label %loop.header
224 define i32 @need_freeze_of_individual_and_conditions4(i1 noundef %cond1, i1 noundef %cond4) {
225 ; CHECK-LABEL: @need_freeze_of_individual_and_conditions4(
227 ; CHECK-NEXT: [[TMP0:%.*]] = or i1 [[COND4:%.*]], [[COND1:%.*]]
228 ; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT_SPLIT:%.*]], label [[ENTRY_SPLIT:%.*]]
229 ; CHECK: entry.split:
230 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
231 ; CHECK: loop.header:
232 ; CHECK-NEXT: [[COND_OR1:%.*]] = or i1 undef, false
233 ; CHECK-NEXT: [[COND_OR6:%.*]] = select i1 [[COND_OR1]], i1 true, i1 false
234 ; CHECK-NEXT: br i1 [[COND_OR6]], label [[EXIT:%.*]], label [[LOOP_LATCH:%.*]]
236 ; CHECK-NEXT: br label [[LOOP_HEADER]]
238 ; CHECK-NEXT: br label [[EXIT_SPLIT]]
240 ; CHECK-NEXT: ret i32 0
243 br label %loop.header
246 %cond_or1 = or i1 undef, %cond1
247 %cond_or6 = select i1 %cond_or1, i1 true, i1 %cond4
248 br i1 %cond_or6, label %exit, label %loop.latch
251 br label %loop.header