Commit 9678c532 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] Fix redundant register moves

Moving a register to itself is not only unnecessary overhead, it also
breaks invariants in the StackTransferRecipe.

R=ahaas@chromium.org

Bug: v8:6600, chromium:793551
Change-Id: I659fd66b4f2d4564c437ed9fb048322af4299d97
Reviewed-on: https://chromium-review.googlesource.com/819231Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49992}
parent 5d9683ee
......@@ -158,7 +158,7 @@ class StackTransferRecipe {
break;
case VarState::kRegister:
DCHECK_EQ(dst.reg_class(), src.reg_class());
MoveRegister(dst, src.reg());
if (dst != src.reg()) MoveRegister(dst, src.reg());
break;
case VarState::kConstant:
LoadConstant(dst, WasmValue(src.i32_const()));
......@@ -167,6 +167,7 @@ class StackTransferRecipe {
}
void MoveRegister(LiftoffRegister dst, LiftoffRegister src) {
DCHECK_NE(dst, src);
DCHECK(!move_dst_regs.has(dst));
move_dst_regs.set(dst);
move_src_regs.set(src);
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
const builder = new WasmModuleBuilder();
builder.addFunction('test', kSig_i_i)
.addBody([
// body:
kExprGetLocal, 0, // get_local 0
kExprGetLocal, 0, // get_local 0
kExprLoop, kWasmStmt, // loop
kExprBr, 0, // br depth=0
kExprEnd, // end
kExprUnreachable, // unreachable
])
.exportFunc();
builder.instantiate();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment