Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1207)

Unified Diff: src/compiler/register-allocator.cc

Issue 1634093002: [turbofan] fine grained in-block move optimization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/move-optimizer.cc ('k') | test/unittests/compiler/move-optimizer-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/register-allocator.cc
diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc
index 065506f4499d5ced632bbd28c4a6f0842e74540e..0465139bba3fdedd614d5b4a06d2be2fcc4999c6 100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -3339,8 +3339,31 @@ void LiveRangeConnector::ResolveControlFlow(Zone* local_zone) {
if (pred_op.Equals(cur_op)) continue;
if (!pred_op.IsAnyRegister() && cur_op.IsAnyRegister()) {
// We're doing a reload.
+ // We don't need to, if:
+ // 1) there's no register use in this block, and
+ // 2) the range ends before the block does, and
+ // 3) we don't have a successor, or the successor is spilled.
+ LifetimePosition block_start =
+ LifetimePosition::GapFromInstructionIndex(block->code_start());
+ LifetimePosition block_end =
+ LifetimePosition::GapFromInstructionIndex(block->code_end());
const LiveRange* current = result.cur_cover_;
-
+ const LiveRange* successor = current->next();
+ if (current->End() < block_end &&
+ (successor == nullptr || successor->spilled())) {
+ // verify point 1: no register use. We can go to the end of the
+ // range, since it's all within the block.
+
+ bool uses_reg = false;
+ for (const UsePosition* use = current->NextUsePosition(block_start);
+ use != nullptr; use = use->next()) {
+ if (use->operand()->IsAnyRegister()) {
+ uses_reg = true;
+ break;
+ }
+ }
+ if (!uses_reg) continue;
+ }
if (current->TopLevel()->IsSpilledOnlyInDeferredBlocks() &&
pred_block->IsDeferred()) {
// The spill location should be defined in pred_block, so add
« no previous file with comments | « src/compiler/move-optimizer.cc ('k') | test/unittests/compiler/move-optimizer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698