Commit 80eb623a authored by sreten.kovacevic's avatar sreten.kovacevic Committed by Commit Bot

[Liftoff][mips] Optimize i32_set_cond instruction

Optimize implementation of i32_set_cond using new macro-assembler
instruction LoadZeroOnCondition. This way, emitting branches is
avoided.

Bug: v8:6600
Change-Id: Icccb2f3714645851fac68a666ddb33db4a9d8062
Reviewed-on: https://chromium-review.googlesource.com/985976
Commit-Queue: Sreten Kovacevic <sreten.kovacevic@mips.com>
Reviewed-by: 's avatarIvica Bogosavljevic <ivica.bogosavljevic@mips.com>
Cr-Commit-Position: refs/heads/master@{#52300}
parent e7105521
......@@ -622,25 +622,19 @@ void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) {
void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst,
Register lhs, Register rhs) {
Label true_label;
if (dst != lhs && dst != rhs) {
ori(dst, zero_reg, 0x1);
Register tmp = dst;
if (dst == lhs || dst == rhs) {
tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
}
// Write 1 as result.
TurboAssembler::li(tmp, 1);
TurboAssembler::Branch(&true_label, cond, lhs, Operand(rhs));
// If not true, set on 0.
TurboAssembler::mov(dst, zero_reg);
// If negative condition is true, write 0 as result.
Condition neg_cond = NegateCondition(cond);
TurboAssembler::LoadZeroOnCondition(tmp, lhs, Operand(rhs), neg_cond);
if (dst != lhs && dst != rhs) {
bind(&true_label);
} else {
Label end_label;
TurboAssembler::Branch(&end_label);
bind(&true_label);
ori(dst, zero_reg, 0x1);
bind(&end_label);
}
// If tmp != dst, result will be moved.
TurboAssembler::Move(dst, tmp);
}
void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) {
......
......@@ -504,25 +504,19 @@ void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) {
void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst,
Register lhs, Register rhs) {
Label true_label;
if (dst != lhs && dst != rhs) {
ori(dst, zero_reg, 0x1);
Register tmp = dst;
if (dst == lhs || dst == rhs) {
tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
}
// Write 1 as result.
TurboAssembler::li(tmp, 1);
TurboAssembler::Branch(&true_label, cond, lhs, Operand(rhs));
// If not true, set on 0.
TurboAssembler::mov(dst, zero_reg);
// If negative condition is true, write 0 as result.
Condition neg_cond = NegateCondition(cond);
TurboAssembler::LoadZeroOnCondition(tmp, lhs, Operand(rhs), neg_cond);
if (dst != lhs && dst != rhs) {
bind(&true_label);
} else {
Label end_label;
TurboAssembler::Branch(&end_label);
bind(&true_label);
ori(dst, zero_reg, 0x1);
bind(&end_label);
}
// If tmp != dst, result will be moved.
TurboAssembler::Move(dst, tmp);
}
void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) {
......
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