Commit d5986f7f authored by dusan.milosavljevic's avatar dusan.milosavljevic Committed by Commit bot

MIPS64: Fix bugs in branches for unsigned conditions.

TEST=cctest/test-branch-combine
BUG=

Review URL: https://codereview.chromium.org/1017733002

Cr-Commit-Position: refs/heads/master@{#27245}
parent cd9b6ec2
...@@ -2122,7 +2122,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, ...@@ -2122,7 +2122,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs,
// Unsigned comparison. // Unsigned comparison.
case Ugreater: case Ugreater:
if (r2.is(zero_reg)) { if (r2.is(zero_reg)) {
bgtz(rs, offset); bne(rs, zero_reg, offset);
} else { } else {
sltu(scratch, r2, rs); sltu(scratch, r2, rs);
bne(scratch, zero_reg, offset); bne(scratch, zero_reg, offset);
...@@ -2130,7 +2130,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, ...@@ -2130,7 +2130,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs,
break; break;
case Ugreater_equal: case Ugreater_equal:
if (r2.is(zero_reg)) { if (r2.is(zero_reg)) {
bgez(rs, offset); b(offset);
} else { } else {
sltu(scratch, rs, r2); sltu(scratch, rs, r2);
beq(scratch, zero_reg, offset); beq(scratch, zero_reg, offset);
...@@ -2147,7 +2147,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, ...@@ -2147,7 +2147,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs,
break; break;
case Uless_equal: case Uless_equal:
if (r2.is(zero_reg)) { if (r2.is(zero_reg)) {
b(offset); beq(rs, zero_reg, offset);
} else { } else {
sltu(scratch, r2, rs); sltu(scratch, r2, rs);
beq(scratch, zero_reg, offset); beq(scratch, zero_reg, offset);
...@@ -2237,7 +2237,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, ...@@ -2237,7 +2237,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs,
// Unsigned comparison. // Unsigned comparison.
case Ugreater: case Ugreater:
if (rt.imm64_ == 0) { if (rt.imm64_ == 0) {
bgtz(rs, offset); bne(rs, zero_reg, offset);
} else { } else {
r2 = scratch; r2 = scratch;
li(r2, rt); li(r2, rt);
...@@ -2247,7 +2247,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, ...@@ -2247,7 +2247,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs,
break; break;
case Ugreater_equal: case Ugreater_equal:
if (rt.imm64_ == 0) { if (rt.imm64_ == 0) {
bgez(rs, offset); b(offset);
} else if (is_int16(rt.imm64_)) { } else if (is_int16(rt.imm64_)) {
sltiu(scratch, rs, rt.imm64_); sltiu(scratch, rs, rt.imm64_);
beq(scratch, zero_reg, offset); beq(scratch, zero_reg, offset);
...@@ -2274,7 +2274,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, ...@@ -2274,7 +2274,7 @@ void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs,
break; break;
case Uless_equal: case Uless_equal:
if (rt.imm64_ == 0) { if (rt.imm64_ == 0) {
b(offset); beq(rs, zero_reg, offset);
} else { } else {
r2 = scratch; r2 = scratch;
li(r2, rt); li(r2, rt);
...@@ -2376,7 +2376,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs, ...@@ -2376,7 +2376,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs,
case Ugreater: case Ugreater:
if (r2.is(zero_reg)) { if (r2.is(zero_reg)) {
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
bgtz(rs, offset); bne(rs, zero_reg, offset);
} else { } else {
sltu(scratch, r2, rs); sltu(scratch, r2, rs);
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
...@@ -2386,7 +2386,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs, ...@@ -2386,7 +2386,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs,
case Ugreater_equal: case Ugreater_equal:
if (r2.is(zero_reg)) { if (r2.is(zero_reg)) {
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
bgez(rs, offset); b(offset);
} else { } else {
sltu(scratch, rs, r2); sltu(scratch, rs, r2);
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
...@@ -2406,7 +2406,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs, ...@@ -2406,7 +2406,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs,
case Uless_equal: case Uless_equal:
if (r2.is(zero_reg)) { if (r2.is(zero_reg)) {
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
b(offset); beq(rs, zero_reg, offset);
} else { } else {
sltu(scratch, r2, rs); sltu(scratch, r2, rs);
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
...@@ -2528,7 +2528,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs, ...@@ -2528,7 +2528,7 @@ void MacroAssembler::BranchShort(Label* L, Condition cond, Register rs,
case Ugreater_equal: case Ugreater_equal:
if (rt.imm64_ == 0) { if (rt.imm64_ == 0) {
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
bgez(rs, offset); b(offset);
} else if (is_int16(rt.imm64_)) { } else if (is_int16(rt.imm64_)) {
sltiu(scratch, rs, rt.imm64_); sltiu(scratch, rs, rt.imm64_);
offset = shifted_branch_offset(L, false); offset = shifted_branch_offset(L, false);
......
...@@ -2976,7 +2976,7 @@ void Simulator::DecodeTypeImmediate(Instruction* instr) { ...@@ -2976,7 +2976,7 @@ void Simulator::DecodeTypeImmediate(Instruction* instr) {
alu_out = (rs < se_imm16) ? 1 : 0; alu_out = (rs < se_imm16) ? 1 : 0;
break; break;
case SLTIU: case SLTIU:
alu_out = (rs_u < static_cast<uint32_t>(se_imm16)) ? 1 : 0; alu_out = (rs_u < static_cast<uint64_t>(se_imm16)) ? 1 : 0;
break; break;
case ANDI: case ANDI:
alu_out = rs & oe_imm16; alu_out = rs & oe_imm16;
......
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