blob: 26c9ab83c2ec5bb989f4223e94d0a8c2fd9dd59d [file] [log] [blame]
Aart Bik281c6812016-08-26 11:31:48 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "loop_optimization.h"
18
Aart Bik96202302016-10-04 17:33:56 -070019#include "linear_order.h"
Aart Bik281c6812016-08-26 11:31:48 -070020
21namespace art {
22
Aart Bik9abf8942016-10-14 09:49:42 -070023// Remove the instruction from the graph. A bit more elaborate than the usual
24// instruction removal, since there may be a cycle in the use structure.
Aart Bik281c6812016-08-26 11:31:48 -070025static void RemoveFromCycle(HInstruction* instruction) {
Aart Bik281c6812016-08-26 11:31:48 -070026 instruction->RemoveAsUserOfAllInputs();
27 instruction->RemoveEnvironmentUsers();
28 instruction->GetBlock()->RemoveInstructionOrPhi(instruction, /*ensure_safety=*/ false);
29}
30
Aart Bik807868e2016-11-03 17:51:43 -070031// Detect a goto block and sets succ to the single successor.
Aart Bike3dedc52016-11-02 17:50:27 -070032static bool IsGotoBlock(HBasicBlock* block, /*out*/ HBasicBlock** succ) {
33 if (block->GetPredecessors().size() == 1 &&
34 block->GetSuccessors().size() == 1 &&
35 block->IsSingleGoto()) {
36 *succ = block->GetSingleSuccessor();
37 return true;
38 }
39 return false;
40}
41
Aart Bik807868e2016-11-03 17:51:43 -070042// Detect an early exit loop.
43static bool IsEarlyExit(HLoopInformation* loop_info) {
44 HBlocksInLoopReversePostOrderIterator it_loop(*loop_info);
45 for (it_loop.Advance(); !it_loop.Done(); it_loop.Advance()) {
46 for (HBasicBlock* successor : it_loop.Current()->GetSuccessors()) {
47 if (!loop_info->Contains(*successor)) {
48 return true;
49 }
50 }
51 }
52 return false;
53}
54
Aart Bik281c6812016-08-26 11:31:48 -070055//
56// Class methods.
57//
58
59HLoopOptimization::HLoopOptimization(HGraph* graph,
60 HInductionVarAnalysis* induction_analysis)
61 : HOptimization(graph, kLoopOptimizationPassName),
62 induction_range_(induction_analysis),
Aart Bik96202302016-10-04 17:33:56 -070063 loop_allocator_(nullptr),
Aart Bik281c6812016-08-26 11:31:48 -070064 top_loop_(nullptr),
Aart Bik8c4a8542016-10-06 11:36:57 -070065 last_loop_(nullptr),
Aart Bik482095d2016-10-10 15:39:10 -070066 iset_(nullptr),
Aart Bikdf7822e2016-12-06 10:05:30 -080067 induction_simplication_count_(0),
68 simplified_(false) {
Aart Bik281c6812016-08-26 11:31:48 -070069}
70
71void HLoopOptimization::Run() {
72 // Well-behaved loops only.
73 // TODO: make this less of a sledgehammer.
Mingyao Yang69d75ff2017-02-07 13:06:06 -080074 if (!graph_->HasLoops() || graph_->HasTryCatch() || graph_->HasIrreducibleLoops()) {
Aart Bik281c6812016-08-26 11:31:48 -070075 return;
76 }
77
Aart Bik96202302016-10-04 17:33:56 -070078 // Phase-local allocator that draws from the global pool. Since the allocator
79 // itself resides on the stack, it is destructed on exiting Run(), which
80 // implies its underlying memory is released immediately.
Nicolas Geoffrayebe16742016-10-05 09:55:42 +010081 ArenaAllocator allocator(graph_->GetArena()->GetArenaPool());
Aart Bik96202302016-10-04 17:33:56 -070082 loop_allocator_ = &allocator;
Nicolas Geoffrayebe16742016-10-05 09:55:42 +010083
Aart Bik96202302016-10-04 17:33:56 -070084 // Perform loop optimizations.
85 LocalRun();
86
Mingyao Yang69d75ff2017-02-07 13:06:06 -080087 if (top_loop_ == nullptr) {
88 graph_->SetHasLoops(false);
89 }
90
Aart Bik96202302016-10-04 17:33:56 -070091 // Detach.
92 loop_allocator_ = nullptr;
93 last_loop_ = top_loop_ = nullptr;
94}
95
96void HLoopOptimization::LocalRun() {
97 // Build the linear order using the phase-local allocator. This step enables building
98 // a loop hierarchy that properly reflects the outer-inner and previous-next relation.
99 ArenaVector<HBasicBlock*> linear_order(loop_allocator_->Adapter(kArenaAllocLinearOrder));
100 LinearizeGraph(graph_, loop_allocator_, &linear_order);
101
Aart Bik281c6812016-08-26 11:31:48 -0700102 // Build the loop hierarchy.
Aart Bik96202302016-10-04 17:33:56 -0700103 for (HBasicBlock* block : linear_order) {
Aart Bik281c6812016-08-26 11:31:48 -0700104 if (block->IsLoopHeader()) {
105 AddLoop(block->GetLoopInformation());
106 }
107 }
Aart Bik96202302016-10-04 17:33:56 -0700108
Aart Bik8c4a8542016-10-06 11:36:57 -0700109 // Traverse the loop hierarchy inner-to-outer and optimize. Traversal can use
110 // a temporary set that stores instructions using the phase-local allocator.
111 if (top_loop_ != nullptr) {
112 ArenaSet<HInstruction*> iset(loop_allocator_->Adapter(kArenaAllocLoopOptimization));
113 iset_ = &iset;
114 TraverseLoopsInnerToOuter(top_loop_);
115 iset_ = nullptr; // detach
116 }
Aart Bik281c6812016-08-26 11:31:48 -0700117}
118
119void HLoopOptimization::AddLoop(HLoopInformation* loop_info) {
120 DCHECK(loop_info != nullptr);
Nicolas Geoffrayebe16742016-10-05 09:55:42 +0100121 LoopNode* node = new (loop_allocator_) LoopNode(loop_info); // phase-local allocator
Aart Bik281c6812016-08-26 11:31:48 -0700122 if (last_loop_ == nullptr) {
123 // First loop.
124 DCHECK(top_loop_ == nullptr);
125 last_loop_ = top_loop_ = node;
126 } else if (loop_info->IsIn(*last_loop_->loop_info)) {
127 // Inner loop.
128 node->outer = last_loop_;
129 DCHECK(last_loop_->inner == nullptr);
130 last_loop_ = last_loop_->inner = node;
131 } else {
132 // Subsequent loop.
133 while (last_loop_->outer != nullptr && !loop_info->IsIn(*last_loop_->outer->loop_info)) {
134 last_loop_ = last_loop_->outer;
135 }
136 node->outer = last_loop_->outer;
137 node->previous = last_loop_;
138 DCHECK(last_loop_->next == nullptr);
139 last_loop_ = last_loop_->next = node;
140 }
141}
142
143void HLoopOptimization::RemoveLoop(LoopNode* node) {
144 DCHECK(node != nullptr);
Aart Bik8c4a8542016-10-06 11:36:57 -0700145 DCHECK(node->inner == nullptr);
146 if (node->previous != nullptr) {
147 // Within sequence.
148 node->previous->next = node->next;
149 if (node->next != nullptr) {
150 node->next->previous = node->previous;
151 }
152 } else {
153 // First of sequence.
154 if (node->outer != nullptr) {
155 node->outer->inner = node->next;
156 } else {
157 top_loop_ = node->next;
158 }
159 if (node->next != nullptr) {
160 node->next->outer = node->outer;
161 node->next->previous = nullptr;
162 }
163 }
Aart Bik281c6812016-08-26 11:31:48 -0700164}
165
166void HLoopOptimization::TraverseLoopsInnerToOuter(LoopNode* node) {
167 for ( ; node != nullptr; node = node->next) {
Aart Bik6b69e0a2017-01-11 10:20:43 -0800168 // Visit inner loops first.
Aart Bik482095d2016-10-10 15:39:10 -0700169 int current_induction_simplification_count = induction_simplication_count_;
Aart Bik281c6812016-08-26 11:31:48 -0700170 if (node->inner != nullptr) {
171 TraverseLoopsInnerToOuter(node->inner);
172 }
Aart Bik6b69e0a2017-01-11 10:20:43 -0800173 // Recompute induction information of this loop if the induction
174 // of any inner loop has been simplified.
Aart Bik482095d2016-10-10 15:39:10 -0700175 if (current_induction_simplification_count != induction_simplication_count_) {
176 induction_range_.ReVisit(node->loop_info);
177 }
Aart Bik6b69e0a2017-01-11 10:20:43 -0800178 // Repeat simplifications in the body of this loop until no more changes occur.
179 // Note that since each simplification consists of eliminating code (without
180 // introducing new code), this process is always finite.
Aart Bikdf7822e2016-12-06 10:05:30 -0800181 do {
182 simplified_ = false;
Aart Bikdf7822e2016-12-06 10:05:30 -0800183 SimplifyInduction(node);
Aart Bik6b69e0a2017-01-11 10:20:43 -0800184 SimplifyBlocks(node);
Aart Bikdf7822e2016-12-06 10:05:30 -0800185 } while (simplified_);
Aart Bik6b69e0a2017-01-11 10:20:43 -0800186 // Simplify inner loop.
Aart Bik9abf8942016-10-14 09:49:42 -0700187 if (node->inner == nullptr) {
Aart Bik6b69e0a2017-01-11 10:20:43 -0800188 SimplifyInnerLoop(node);
Aart Bik9abf8942016-10-14 09:49:42 -0700189 }
Aart Bik281c6812016-08-26 11:31:48 -0700190 }
191}
192
193void HLoopOptimization::SimplifyInduction(LoopNode* node) {
194 HBasicBlock* header = node->loop_info->GetHeader();
195 HBasicBlock* preheader = node->loop_info->GetPreHeader();
Aart Bik8c4a8542016-10-06 11:36:57 -0700196 // Scan the phis in the header to find opportunities to simplify an induction
197 // cycle that is only used outside the loop. Replace these uses, if any, with
198 // the last value and remove the induction cycle.
199 // Examples: for (int i = 0; x != null; i++) { .... no i .... }
200 // for (int i = 0; i < 10; i++, k++) { .... no k .... } return k;
Aart Bik281c6812016-08-26 11:31:48 -0700201 for (HInstructionIterator it(header->GetPhis()); !it.Done(); it.Advance()) {
202 HPhi* phi = it.Current()->AsPhi();
Aart Bik8c4a8542016-10-06 11:36:57 -0700203 iset_->clear();
204 int32_t use_count = 0;
Aart Bikcc42be02016-10-20 16:14:16 -0700205 if (IsPhiInduction(phi) &&
Aart Bik6b69e0a2017-01-11 10:20:43 -0800206 IsOnlyUsedAfterLoop(node->loop_info, phi, /*collect_loop_uses*/ false, &use_count) &&
Aart Bik807868e2016-11-03 17:51:43 -0700207 // No uses, or no early-exit with proper replacement.
208 (use_count == 0 ||
209 (!IsEarlyExit(node->loop_info) && TryReplaceWithLastValue(phi, preheader)))) {
Aart Bik8c4a8542016-10-06 11:36:57 -0700210 for (HInstruction* i : *iset_) {
211 RemoveFromCycle(i);
Aart Bik281c6812016-08-26 11:31:48 -0700212 }
Aart Bikdf7822e2016-12-06 10:05:30 -0800213 simplified_ = true;
Aart Bik482095d2016-10-10 15:39:10 -0700214 }
215 }
216}
217
218void HLoopOptimization::SimplifyBlocks(LoopNode* node) {
Aart Bikdf7822e2016-12-06 10:05:30 -0800219 // Iterate over all basic blocks in the loop-body.
220 for (HBlocksInLoopIterator it(*node->loop_info); !it.Done(); it.Advance()) {
221 HBasicBlock* block = it.Current();
222 // Remove dead instructions from the loop-body.
Aart Bik6b69e0a2017-01-11 10:20:43 -0800223 RemoveDeadInstructions(block->GetPhis());
224 RemoveDeadInstructions(block->GetInstructions());
Aart Bikdf7822e2016-12-06 10:05:30 -0800225 // Remove trivial control flow blocks from the loop-body.
Aart Bik6b69e0a2017-01-11 10:20:43 -0800226 if (block->GetPredecessors().size() == 1 &&
227 block->GetSuccessors().size() == 1 &&
228 block->GetSingleSuccessor()->GetPredecessors().size() == 1) {
Aart Bikdf7822e2016-12-06 10:05:30 -0800229 simplified_ = true;
Aart Bik6b69e0a2017-01-11 10:20:43 -0800230 block->MergeWith(block->GetSingleSuccessor());
Aart Bikdf7822e2016-12-06 10:05:30 -0800231 } else if (block->GetSuccessors().size() == 2) {
232 // Trivial if block can be bypassed to either branch.
233 HBasicBlock* succ0 = block->GetSuccessors()[0];
234 HBasicBlock* succ1 = block->GetSuccessors()[1];
235 HBasicBlock* meet0 = nullptr;
236 HBasicBlock* meet1 = nullptr;
237 if (succ0 != succ1 &&
238 IsGotoBlock(succ0, &meet0) &&
239 IsGotoBlock(succ1, &meet1) &&
240 meet0 == meet1 && // meets again
241 meet0 != block && // no self-loop
242 meet0->GetPhis().IsEmpty()) { // not used for merging
243 simplified_ = true;
244 succ0->DisconnectAndDelete();
245 if (block->Dominates(meet0)) {
246 block->RemoveDominatedBlock(meet0);
247 succ1->AddDominatedBlock(meet0);
248 meet0->SetDominator(succ1);
Aart Bike3dedc52016-11-02 17:50:27 -0700249 }
Aart Bik482095d2016-10-10 15:39:10 -0700250 }
Aart Bik281c6812016-08-26 11:31:48 -0700251 }
Aart Bikdf7822e2016-12-06 10:05:30 -0800252 }
Aart Bik281c6812016-08-26 11:31:48 -0700253}
254
Aart Bik6b69e0a2017-01-11 10:20:43 -0800255bool HLoopOptimization::SimplifyInnerLoop(LoopNode* node) {
Aart Bik281c6812016-08-26 11:31:48 -0700256 HBasicBlock* header = node->loop_info->GetHeader();
257 HBasicBlock* preheader = node->loop_info->GetPreHeader();
Aart Bik9abf8942016-10-14 09:49:42 -0700258 // Ensure loop header logic is finite.
Aart Bik6b69e0a2017-01-11 10:20:43 -0800259 int64_t tc = 0;
260 if (!induction_range_.IsFinite(node->loop_info, &tc)) {
261 return false;
Aart Bik9abf8942016-10-14 09:49:42 -0700262 }
Aart Bik281c6812016-08-26 11:31:48 -0700263 // Ensure there is only a single loop-body (besides the header).
264 HBasicBlock* body = nullptr;
265 for (HBlocksInLoopIterator it(*node->loop_info); !it.Done(); it.Advance()) {
266 if (it.Current() != header) {
267 if (body != nullptr) {
Aart Bik6b69e0a2017-01-11 10:20:43 -0800268 return false;
Aart Bik281c6812016-08-26 11:31:48 -0700269 }
270 body = it.Current();
271 }
272 }
273 // Ensure there is only a single exit point.
274 if (header->GetSuccessors().size() != 2) {
Aart Bik6b69e0a2017-01-11 10:20:43 -0800275 return false;
Aart Bik281c6812016-08-26 11:31:48 -0700276 }
277 HBasicBlock* exit = (header->GetSuccessors()[0] == body)
278 ? header->GetSuccessors()[1]
279 : header->GetSuccessors()[0];
Aart Bik8c4a8542016-10-06 11:36:57 -0700280 // Ensure exit can only be reached by exiting loop.
Aart Bik281c6812016-08-26 11:31:48 -0700281 if (exit->GetPredecessors().size() != 1) {
Aart Bik6b69e0a2017-01-11 10:20:43 -0800282 return false;
Aart Bik281c6812016-08-26 11:31:48 -0700283 }
Aart Bik6b69e0a2017-01-11 10:20:43 -0800284 // Detect either an empty loop (no side effects other than plain iteration) or
285 // a trivial loop (just iterating once). Replace subsequent index uses, if any,
286 // with the last value and remove the loop, possibly after unrolling its body.
287 HInstruction* phi = header->GetFirstPhi();
Aart Bik8c4a8542016-10-06 11:36:57 -0700288 iset_->clear();
289 int32_t use_count = 0;
Aart Bik6b69e0a2017-01-11 10:20:43 -0800290 if (IsEmptyHeader(header)) {
291 bool is_empty = IsEmptyBody(body);
292 if ((is_empty || tc == 1) &&
293 IsOnlyUsedAfterLoop(node->loop_info, phi, /*collect_loop_uses*/ true, &use_count) &&
294 // No uses, or proper replacement.
295 (use_count == 0 || TryReplaceWithLastValue(phi, preheader))) {
296 if (!is_empty) {
297 // Unroll the loop body, which sees initial value of the index.
298 phi->ReplaceWith(phi->InputAt(0));
299 preheader->MergeInstructionsWith(body);
300 }
301 body->DisconnectAndDelete();
302 exit->RemovePredecessor(header);
303 header->RemoveSuccessor(exit);
304 header->RemoveDominatedBlock(exit);
305 header->DisconnectAndDelete();
306 preheader->AddSuccessor(exit);
307 preheader->AddInstruction(new (graph_->GetArena()) HGoto()); // global allocator
308 preheader->AddDominatedBlock(exit);
309 exit->SetDominator(preheader);
310 RemoveLoop(node); // update hierarchy
311 return true;
312 }
Aart Bik281c6812016-08-26 11:31:48 -0700313 }
Aart Bik6b69e0a2017-01-11 10:20:43 -0800314 return false;
Aart Bik281c6812016-08-26 11:31:48 -0700315}
316
Aart Bikcc42be02016-10-20 16:14:16 -0700317bool HLoopOptimization::IsPhiInduction(HPhi* phi) {
318 ArenaSet<HInstruction*>* set = induction_range_.LookupCycle(phi);
319 if (set != nullptr) {
Aart Bike3dedc52016-11-02 17:50:27 -0700320 DCHECK(iset_->empty());
Aart Bikcc42be02016-10-20 16:14:16 -0700321 for (HInstruction* i : *set) {
Aart Bike3dedc52016-11-02 17:50:27 -0700322 // Check that, other than instructions that are no longer in the graph (removed earlier)
323 // each instruction is removable and, other than the phi, uses are contained in the cycle.
324 if (!i->IsInBlock()) {
325 continue;
326 } else if (!i->IsRemovable()) {
327 return false;
328 } else if (i != phi) {
Aart Bikcc42be02016-10-20 16:14:16 -0700329 for (const HUseListNode<HInstruction*>& use : i->GetUses()) {
330 if (set->find(use.GetUser()) == set->end()) {
331 return false;
332 }
333 }
334 }
Aart Bike3dedc52016-11-02 17:50:27 -0700335 iset_->insert(i); // copy
Aart Bikcc42be02016-10-20 16:14:16 -0700336 }
Aart Bikcc42be02016-10-20 16:14:16 -0700337 return true;
338 }
339 return false;
340}
341
342// Find: phi: Phi(init, addsub)
343// s: SuspendCheck
344// c: Condition(phi, bound)
345// i: If(c)
346// TODO: Find a less pattern matching approach?
347bool HLoopOptimization::IsEmptyHeader(HBasicBlock* block) {
348 DCHECK(iset_->empty());
349 HInstruction* phi = block->GetFirstPhi();
350 if (phi != nullptr && phi->GetNext() == nullptr && IsPhiInduction(phi->AsPhi())) {
351 HInstruction* s = block->GetFirstInstruction();
352 if (s != nullptr && s->IsSuspendCheck()) {
353 HInstruction* c = s->GetNext();
354 if (c != nullptr && c->IsCondition() && c->GetUses().HasExactlyOneElement()) {
355 HInstruction* i = c->GetNext();
356 if (i != nullptr && i->IsIf() && i->InputAt(0) == c) {
357 iset_->insert(c);
358 iset_->insert(s);
359 return true;
360 }
361 }
362 }
363 }
364 return false;
365}
366
367bool HLoopOptimization::IsEmptyBody(HBasicBlock* block) {
368 if (block->GetFirstPhi() == nullptr) {
369 for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
370 HInstruction* instruction = it.Current();
371 if (!instruction->IsGoto() && iset_->find(instruction) == iset_->end()) {
372 return false;
373 }
374 }
375 return true;
376 }
377 return false;
378}
379
Aart Bik482095d2016-10-10 15:39:10 -0700380bool HLoopOptimization::IsOnlyUsedAfterLoop(HLoopInformation* loop_info,
Aart Bik8c4a8542016-10-06 11:36:57 -0700381 HInstruction* instruction,
Aart Bik6b69e0a2017-01-11 10:20:43 -0800382 bool collect_loop_uses,
Aart Bik8c4a8542016-10-06 11:36:57 -0700383 /*out*/ int32_t* use_count) {
384 for (const HUseListNode<HInstruction*>& use : instruction->GetUses()) {
385 HInstruction* user = use.GetUser();
386 if (iset_->find(user) == iset_->end()) { // not excluded?
387 HLoopInformation* other_loop_info = user->GetBlock()->GetLoopInformation();
Aart Bik482095d2016-10-10 15:39:10 -0700388 if (other_loop_info != nullptr && other_loop_info->IsIn(*loop_info)) {
Aart Bik6b69e0a2017-01-11 10:20:43 -0800389 // If collect_loop_uses is set, simply keep adding those uses to the set.
390 // Otherwise, reject uses inside the loop that were not already in the set.
391 if (collect_loop_uses) {
392 iset_->insert(user);
393 continue;
394 }
Aart Bik8c4a8542016-10-06 11:36:57 -0700395 return false;
396 }
397 ++*use_count;
398 }
399 }
400 return true;
401}
402
Aart Bik807868e2016-11-03 17:51:43 -0700403bool HLoopOptimization::TryReplaceWithLastValue(HInstruction* instruction, HBasicBlock* block) {
404 // Try to replace outside uses with the last value. Environment uses can consume this
405 // value too, since any first true use is outside the loop (although this may imply
406 // that de-opting may look "ahead" a bit on the phi value). If there are only environment
407 // uses, the value is dropped altogether, since the computations have no effect.
408 if (induction_range_.CanGenerateLastValue(instruction)) {
Aart Bik6b69e0a2017-01-11 10:20:43 -0800409 HInstruction* replacement = induction_range_.GenerateLastValue(instruction, graph_, block);
410 const HUseList<HInstruction*>& uses = instruction->GetUses();
411 for (auto it = uses.begin(), end = uses.end(); it != end;) {
412 HInstruction* user = it->GetUser();
413 size_t index = it->GetIndex();
414 ++it; // increment before replacing
415 if (iset_->find(user) == iset_->end()) { // not excluded?
416 user->ReplaceInput(replacement, index);
417 induction_range_.Replace(user, instruction, replacement); // update induction
418 }
419 }
420 const HUseList<HEnvironment*>& env_uses = instruction->GetEnvUses();
421 for (auto it = env_uses.begin(), end = env_uses.end(); it != end;) {
422 HEnvironment* user = it->GetUser();
423 size_t index = it->GetIndex();
424 ++it; // increment before replacing
425 if (iset_->find(user->GetHolder()) == iset_->end()) { // not excluded?
426 user->RemoveAsUserOfInput(index);
427 user->SetRawEnvAt(index, replacement);
428 replacement->AddEnvUseAt(user, index);
429 }
430 }
431 induction_simplication_count_++;
Aart Bik807868e2016-11-03 17:51:43 -0700432 return true;
Aart Bik8c4a8542016-10-06 11:36:57 -0700433 }
Aart Bik807868e2016-11-03 17:51:43 -0700434 return false;
Aart Bik8c4a8542016-10-06 11:36:57 -0700435}
436
Aart Bik6b69e0a2017-01-11 10:20:43 -0800437void HLoopOptimization::RemoveDeadInstructions(const HInstructionList& list) {
438 for (HBackwardInstructionIterator i(list); !i.Done(); i.Advance()) {
439 HInstruction* instruction = i.Current();
440 if (instruction->IsDeadAndRemovable()) {
441 simplified_ = true;
442 instruction->GetBlock()->RemoveInstructionOrPhi(instruction);
443 }
444 }
445}
446
Aart Bik281c6812016-08-26 11:31:48 -0700447} // namespace art