Index: src/ia32/assembler-ia32.cc |
diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc |
index e5456da474673b69ad785532dae8319f10a89e39..c2e843197f674b6cccff95f2cd99f3c309c162a7 100644 |
--- a/src/ia32/assembler-ia32.cc |
+++ b/src/ia32/assembler-ia32.cc |
@@ -1131,30 +1131,21 @@ void Assembler::sub(const Operand& dst, Register src) { |
void Assembler::test(Register reg, const Immediate& imm) { |
+ if (RelocInfo::IsNone(imm.rmode_) && is_uint8(imm.x_)) { |
+ test_b(reg, imm.x_); |
+ return; |
+ } |
+ |
EnsureSpace ensure_space(this); |
- // Only use test against byte for registers that have a byte |
- // variant: eax, ebx, ecx, and edx. |
- if (RelocInfo::IsNone(imm.rmode_) && |
- is_uint8(imm.x_) && |
- reg.is_byte_register()) { |
- uint8_t imm8 = imm.x_; |
- if (reg.is(eax)) { |
- EMIT(0xA8); |
- EMIT(imm8); |
- } else { |
- emit_arith_b(0xF6, 0xC0, reg, imm8); |
- } |
+ // This is not using emit_arith because test doesn't support |
+ // sign-extension of 8-bit operands. |
+ if (reg.is(eax)) { |
+ EMIT(0xA9); |
} else { |
- // This is not using emit_arith because test doesn't support |
- // sign-extension of 8-bit operands. |
- if (reg.is(eax)) { |
- EMIT(0xA9); |
- } else { |
- EMIT(0xF7); |
- EMIT(0xC0 | reg.code()); |
- } |
- emit(imm); |
+ EMIT(0xF7); |
+ EMIT(0xC0 | reg.code()); |
} |
+ emit(imm); |
} |
@@ -1178,6 +1169,9 @@ void Assembler::test(const Operand& op, const Immediate& imm) { |
test(op.reg(), imm); |
return; |
} |
+ if (RelocInfo::IsNone(imm.rmode_) && is_uint8(imm.x_)) { |
+ return test_b(op, imm.x_); |
+ } |
EnsureSpace ensure_space(this); |
EMIT(0xF7); |
emit_operand(eax, op); |
@@ -1185,9 +1179,26 @@ void Assembler::test(const Operand& op, const Immediate& imm) { |
} |
+void Assembler::test_b(Register reg, uint8_t imm8) { |
+ EnsureSpace ensure_space(this); |
+ // Only use test against byte for registers that have a byte |
+ // variant: eax, ebx, ecx, and edx. |
+ if (reg.is(eax)) { |
+ EMIT(0xA8); |
+ EMIT(imm8); |
+ } else if (reg.is_byte_register()) { |
+ emit_arith_b(0xF6, 0xC0, reg, imm8); |
+ } else { |
+ EMIT(0xF7); |
+ EMIT(0xC0 | reg.code()); |
+ emit(imm8); |
+ } |
+} |
+ |
+ |
void Assembler::test_b(const Operand& op, uint8_t imm8) { |
- if (op.is_reg_only() && !op.reg().is_byte_register()) { |
- test(op, Immediate(imm8)); |
+ if (op.is_reg_only()) { |
+ test_b(op.reg(), imm8); |
return; |
} |
EnsureSpace ensure_space(this); |