Index: src/x64/assembler-x64.cc |
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc |
index 5402a8ce87a3987981e1c8a33340238b95b517c3..7a7fc6c87bcae85226d288b86a25060ab907ac49 100644 |
--- a/src/x64/assembler-x64.cc |
+++ b/src/x64/assembler-x64.cc |
@@ -2103,11 +2103,12 @@ void Assembler::testb(const Operand& op, Register reg) { |
void Assembler::testw(Register dst, Register src) { |
EnsureSpace ensure_space(this); |
emit(0x66); |
- if (src.low_bits() == 4) { |
- emit_rex_32(src, dst); |
+ if (!dst.is_byte_register() || !src.is_byte_register()) { |
+ // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
+ emit_rex_32(dst, src); |
} |
emit(0x85); |
- emit_modrm(src, dst); |
+ emit_modrm(dst, src); |
} |
void Assembler::testw(Register reg, Immediate mask) { |
@@ -2118,7 +2119,7 @@ void Assembler::testw(Register reg, Immediate mask) { |
emit(0xA9); |
emitw(mask.value_); |
} else { |
- if (reg.low_bits() == 4) { |
+ if (!reg.is_byte_register()) { |
emit_rex_32(reg); |
} |
emit(0xF7); |