Merge "Fix x64's cmpw."
diff --git a/compiler/utils/x86_64/assembler_x86_64.cc b/compiler/utils/x86_64/assembler_x86_64.cc
index 89d7915..6e7d74d 100644
--- a/compiler/utils/x86_64/assembler_x86_64.cc
+++ b/compiler/utils/x86_64/assembler_x86_64.cc
@@ -1213,8 +1213,8 @@
 
 void X86_64Assembler::cmpw(const Address& address, const Immediate& imm) {
   AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+  EmitOperandSizeOverride();
   EmitOptionalRex32(address);
-  EmitUint8(0x66);
   EmitComplex(7, address, imm);
 }
 
diff --git a/compiler/utils/x86_64/assembler_x86_64_test.cc b/compiler/utils/x86_64/assembler_x86_64_test.cc
index 82378f7..00bb5ca 100644
--- a/compiler/utils/x86_64/assembler_x86_64_test.cc
+++ b/compiler/utils/x86_64/assembler_x86_64_test.cc
@@ -755,10 +755,34 @@
 TEST_F(AssemblerX86_64Test, Movw) {
   GetAssembler()->movw(x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
                        x86_64::CpuRegister(x86_64::R9));
-  const char* expected = "movw %R9w, 0(%RAX)\n";
+  GetAssembler()->movw(x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
+                       x86_64::Immediate(0));
+  GetAssembler()->movw(x86_64::Address(x86_64::CpuRegister(x86_64::R9), 0),
+                       x86_64::Immediate(0));
+  GetAssembler()->movw(x86_64::Address(x86_64::CpuRegister(x86_64::R14), 0),
+                       x86_64::Immediate(0));
+  const char* expected =
+      "movw %R9w, 0(%RAX)\n"
+      "movw $0, 0(%RAX)\n"
+      "movw $0, 0(%R9)\n"
+      "movw $0, 0(%R14)\n";
   DriverStr(expected, "movw");
 }
 
+TEST_F(AssemblerX86_64Test, Cmpw) {
+  GetAssembler()->cmpw(x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
+                       x86_64::Immediate(0));
+  GetAssembler()->cmpw(x86_64::Address(x86_64::CpuRegister(x86_64::R9), 0),
+                       x86_64::Immediate(0));
+  GetAssembler()->cmpw(x86_64::Address(x86_64::CpuRegister(x86_64::R14), 0),
+                       x86_64::Immediate(0));
+  const char* expected =
+      "cmpw $0, 0(%RAX)\n"
+      "cmpw $0, 0(%R9)\n"
+      "cmpw $0, 0(%R14)\n";
+  DriverStr(expected, "cmpw");
+}
+
 TEST_F(AssemblerX86_64Test, MovqAddrImm) {
   GetAssembler()->movq(x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
                        x86_64::Immediate(-5));