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) { ...@@ -622,25 +622,19 @@ void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) {
void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst,
Register lhs, Register rhs) { Register lhs, Register rhs) {
Label true_label; Register tmp = dst;
if (dst != lhs && dst != rhs) { if (dst == lhs || dst == rhs) {
ori(dst, zero_reg, 0x1); 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 negative condition is true, write 0 as result.
// If not true, set on 0. Condition neg_cond = NegateCondition(cond);
TurboAssembler::mov(dst, zero_reg); TurboAssembler::LoadZeroOnCondition(tmp, lhs, Operand(rhs), neg_cond);
if (dst != lhs && dst != rhs) { // If tmp != dst, result will be moved.
bind(&true_label); TurboAssembler::Move(dst, tmp);
} else {
Label end_label;
TurboAssembler::Branch(&end_label);
bind(&true_label);
ori(dst, zero_reg, 0x1);
bind(&end_label);
}
} }
void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) {
......
...@@ -504,25 +504,19 @@ void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) { ...@@ -504,25 +504,19 @@ void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) {
void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst,
Register lhs, Register rhs) { Register lhs, Register rhs) {
Label true_label; Register tmp = dst;
if (dst != lhs && dst != rhs) { if (dst == lhs || dst == rhs) {
ori(dst, zero_reg, 0x1); 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 negative condition is true, write 0 as result.
// If not true, set on 0. Condition neg_cond = NegateCondition(cond);
TurboAssembler::mov(dst, zero_reg); TurboAssembler::LoadZeroOnCondition(tmp, lhs, Operand(rhs), neg_cond);
if (dst != lhs && dst != rhs) { // If tmp != dst, result will be moved.
bind(&true_label); TurboAssembler::Move(dst, tmp);
} else {
Label end_label;
TurboAssembler::Branch(&end_label);
bind(&true_label);
ori(dst, zero_reg, 0x1);
bind(&end_label);
}
} }
void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { 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