From ac9f18274676baab2dc90c6f9431738c6e9c17d5 Mon Sep 17 00:00:00 2001 From: mtrofin Date: Thu, 25 Feb 2016 07:40:46 -0800 Subject: [PATCH] [turbofan] don't take hints from deferred blocks We should prefer hints from operands in non-deferred blocks, else we risk sideways moves on the hot path, just to accommodate the register allocator's choice of register assignment in the deferred block. BUG= Review URL: https://codereview.chromium.org/1718223002 Cr-Commit-Position: refs/heads/master@{#34296} --- src/compiler/register-allocator.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc index 02ba1f17c2..fec5d1b027 100644 --- a/src/compiler/register-allocator.cc +++ b/src/compiler/register-allocator.cc @@ -2197,8 +2197,22 @@ void LiveRangeBuilder::ProcessPhis(const InstructionBlock* block, int phi_vreg = phi->virtual_register(); live->Remove(phi_vreg); InstructionOperand* hint = nullptr; - Instruction* instr = GetLastInstruction( - code(), code()->InstructionBlockAt(block->predecessors()[0])); + const InstructionBlock::Predecessors& predecessors = block->predecessors(); + const InstructionBlock* predecessor_block = + code()->InstructionBlockAt(predecessors[0]); + const Instruction* instr = GetLastInstruction(code(), predecessor_block); + if (predecessor_block->IsDeferred()) { + // "Prefer the hint from the first non-deferred predecessor, if any. + for (size_t i = 1; i < predecessors.size(); ++i) { + predecessor_block = code()->InstructionBlockAt(predecessors[i]); + if (!predecessor_block->IsDeferred()) { + instr = GetLastInstruction(code(), predecessor_block); + break; + } + } + } + DCHECK_NOT_NULL(instr); + for (MoveOperands* move : *instr->GetParallelMove(Instruction::END)) { InstructionOperand& to = move->destination(); if (to.IsUnallocated() &&