summaryrefslogtreecommitdiff
path: root/compiler/optimizing/loop_optimization.cc
diff options
context:
space:
mode:
authorAart Bik <ajcbik@google.com>2017-04-05 10:03:15 -0700
committerAart Bik <ajcbik@google.com>2017-04-05 10:03:15 -0700
commitb07d1bcf055d3eb8c6b4c45b359ad8ef30909af7 (patch)
treee925d6df31a3da17757c5d3f1b4f32c341847ce5 /compiler/optimizing/loop_optimization.cc
parentf6e11e9e218e5e70463b5b3a94c89309936601d7 (diff)
Ensure environment is ready when populating loop.
Rationale: OSR requires the suspend check to already have an environment, albeit just for testing irreducible loops. This CL fixes the omission. Note, the error is spurious on OSR and writing a unit or regression test for this is hard. Test: test-art-host Bug: 36950873 Change-Id: Ica89e18e10deb438dead79e2cc40dd00a60b529f
Diffstat (limited to 'compiler/optimizing/loop_optimization.cc')
-rw-r--r--compiler/optimizing/loop_optimization.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index 42ed04dfa3..0d84c4dd03 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -533,29 +533,25 @@ void HLoopOptimization::GenerateNewLoop(LoopNode* node,
kNoRegNumber,
0,
HPhi::ToPhiType(induc_type));
- // Generate header.
+ // Generate header and prepare body.
// for (i = lo; i < hi; i += step)
// <loop-body>
HInstruction* cond = new (global_allocator_) HAboveOrEqual(vector_phi_, hi);
vector_header_->AddPhi(vector_phi_);
vector_header_->AddInstruction(cond);
vector_header_->AddInstruction(new (global_allocator_) HIf(cond));
- // Suspend check and environment.
- HInstruction* suspend = vector_header_->GetFirstInstruction();
- suspend->CopyEnvironmentFromWithLoopPhiAdjustment(
- node->loop_info->GetSuspendCheck()->GetEnvironment(), vector_header_);
- // Generate body.
for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
bool vectorized_def = VectorizeDef(node, it.Current(), /*generate_code*/ true);
DCHECK(vectorized_def);
}
+ // Generate body.
+ HEnvironment* env = vector_header_->GetFirstInstruction()->GetEnvironment();
for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
auto i = vector_map_->find(it.Current());
if (i != vector_map_->end() && !i->second->IsInBlock()) {
Insert(vector_body_, i->second); // lays out in original order
if (i->second->NeedsEnvironment()) {
- i->second->CopyEnvironmentFromWithLoopPhiAdjustment(
- suspend->GetEnvironment(), vector_header_);
+ i->second->CopyEnvironmentFromWithLoopPhiAdjustment(env, vector_header_);
}
}
}