From dde7963d36c81663e39f0df8ec5b3f8faec2d852 Mon Sep 17 00:00:00 2001 From: "vegorov@google.com" Date: Mon, 20 Oct 2014 11:29:19 +0000 Subject: [PATCH] Ignore redundant parallel moves when checking if a block is empty. Single predecessor blocks containing nothing but redundant parallel moves can be compacted away. R=zerny@google.com BUG=http://dartbug.com/21302 Review URL: https://codereview.chromium.org//669613003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41187 260f80e4-7a28-3924-810f-c04153c831b5 --- runtime/vm/flow_graph_compiler.cc | 4 ++-- runtime/vm/intermediate_language.cc | 10 ++++++++++ runtime/vm/intermediate_language.h | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc index ce31710dcca..d3258f98b9d 100644 --- a/runtime/vm/flow_graph_compiler.cc +++ b/runtime/vm/flow_graph_compiler.cc @@ -225,9 +225,9 @@ bool FlowGraphCompiler::ForceSlowPathForStackOverflow() const { static bool IsEmptyBlock(BlockEntryInstr* block) { - return !block->HasParallelMove() && + return !block->HasNonRedundantParallelMove() && block->next()->IsGoto() && - !block->next()->AsGoto()->HasParallelMove(); + !block->next()->AsGoto()->HasNonRedundantParallelMove(); } diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc index ce6092afed4..c9c196855c5 100644 --- a/runtime/vm/intermediate_language.cc +++ b/runtime/vm/intermediate_language.cc @@ -2566,6 +2566,16 @@ void ParameterInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } +bool ParallelMoveInstr::IsRedundant() const { + for (intptr_t i = 0; i < moves_.length(); i++) { + if (!moves_[i]->IsRedundant()) { + return false; + } + } + return true; +} + + LocationSummary* ParallelMoveInstr::MakeLocationSummary(Isolate* isolate, bool optimizing) const { return NULL; diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h index 923b88334b8..2f46de57edc 100644 --- a/runtime/vm/intermediate_language.h +++ b/runtime/vm/intermediate_language.h @@ -1078,6 +1078,8 @@ class ParallelMoveInstr : public TemplateInstruction<0> { intptr_t NumMoves() const { return moves_.length(); } + bool IsRedundant() const; + virtual void PrintTo(BufferFormatter* f) const; virtual bool MayThrow() const { return false; } @@ -1138,6 +1140,10 @@ class BlockEntryInstr : public Instruction { return parallel_move_ != NULL; } + bool HasNonRedundantParallelMove() const { + return HasParallelMove() && !parallel_move()->IsRedundant(); + } + ParallelMoveInstr* GetParallelMove() { if (parallel_move_ == NULL) { parallel_move_ = new ParallelMoveInstr(); @@ -2167,6 +2173,10 @@ class GotoInstr : public TemplateInstruction<0> { return parallel_move_ != NULL; } + bool HasNonRedundantParallelMove() const { + return HasParallelMove() && !parallel_move()->IsRedundant(); + } + ParallelMoveInstr* GetParallelMove() { if (parallel_move_ == NULL) { parallel_move_ = new ParallelMoveInstr();