Fix a MOV instruction in Optimizing's x86-64 code generator.
Use `movl' instead of `movw' to store a 32-bit immediate
(integer or reference) into a field.
Also fix art::Location::RegisterOrInt32LongConstant to
properly handle non-long constants.
Change-Id: I34c6ec8eaa1632822a31969f87c9c2d6c5b96326
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index 22f5d96..afffbe2 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -3337,7 +3337,7 @@
case Primitive::kPrimNot: {
if (value.IsConstant()) {
int32_t v = CodeGenerator::GetInt32ValueOf(value.GetConstant());
- __ movw(Address(base, offset), Immediate(v));
+ __ movl(Address(base, offset), Immediate(v));
} else {
__ movl(Address(base, offset), value.AsRegister<CpuRegister>());
}
diff --git a/compiler/optimizing/locations.cc b/compiler/optimizing/locations.cc
index 42aba04..d14dfc1 100644
--- a/compiler/optimizing/locations.cc
+++ b/compiler/optimizing/locations.cc
@@ -51,16 +51,17 @@
}
Location Location::RegisterOrInt32LongConstant(HInstruction* instruction) {
- if (!instruction->IsConstant() || !instruction->AsConstant()->IsLongConstant()) {
+ if (instruction->IsIntConstant() || instruction->IsNullConstant()) {
+ return Location::ConstantLocation(instruction->AsConstant());
+ } else if (instruction->IsLongConstant()) {
+ // Does the long constant fit in a 32 bit int?
+ int64_t value = instruction->AsLongConstant()->GetValue();
+ return IsInt<32>(value)
+ ? Location::ConstantLocation(instruction->AsConstant())
+ : Location::RequiresRegister();
+ } else {
return Location::RequiresRegister();
}
-
- // Does the long constant fit in a 32 bit int?
- int64_t value = instruction->AsConstant()->AsLongConstant()->GetValue();
-
- return IsInt<32>(value)
- ? Location::ConstantLocation(instruction->AsConstant())
- : Location::RequiresRegister();
}
Location Location::ByteRegisterOrConstant(int reg, HInstruction* instruction) {