From 755686e5b21665c239f4207116fc5976d7b493ee Mon Sep 17 00:00:00 2001 From: Aske Simon Christensen Date: Mon, 15 Jun 2020 08:59:35 +0000 Subject: [PATCH] [vm] Simplify RemoveRedefinitions. Instead of having identical cases for every instruction that implements RedefinedValue, just have one generic piece of code. Change-Id: If3f4905a578eb345ae3d740d1f539d346c6223af Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150985 Reviewed-by: Vyacheslav Egorov Commit-Queue: Aske Simon Christensen --- runtime/vm/compiler/backend/flow_graph.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/runtime/vm/compiler/backend/flow_graph.cc b/runtime/vm/compiler/backend/flow_graph.cc index fd395e0cf74a..c285c5180caa 100644 --- a/runtime/vm/compiler/backend/flow_graph.cc +++ b/runtime/vm/compiler/backend/flow_graph.cc @@ -1669,21 +1669,12 @@ void FlowGraph::RemoveRedefinitions(bool keep_checks) { instr_it.RemoveCurrentFromGraph(); } else if (keep_checks) { continue; - } else if (auto check = instruction->AsCheckArrayBound()) { - check->ReplaceUsesWith(check->index()->definition()); - check->ClearSSATempIndex(); - } else if (auto check = instruction->AsGenericCheckBound()) { - check->ReplaceUsesWith(check->index()->definition()); - check->ClearSSATempIndex(); - } else if (auto check = instruction->AsCheckNull()) { - check->ReplaceUsesWith(check->value()->definition()); - check->ClearSSATempIndex(); - } else if (auto check = instruction->AsAssertAssignable()) { - check->ReplaceUsesWith(check->value()->definition()); - check->ClearSSATempIndex(); - } else if (auto check = instruction->AsAssertBoolean()) { - check->ReplaceUsesWith(check->value()->definition()); - check->ClearSSATempIndex(); + } else if (auto def = instruction->AsDefinition()) { + Value* value = def->RedefinedValue(); + if (value != nullptr) { + def->ReplaceUsesWith(value->definition()); + def->ClearSSATempIndex(); + } } } }