OSDN Git Service

Optimizing: Clean up constant location handling.
authorVladimir Marko <vmarko@google.com>
Wed, 11 Nov 2015 12:37:46 +0000 (12:37 +0000)
committerVladimir Marko <vmarko@google.com>
Wed, 11 Nov 2015 16:33:27 +0000 (16:33 +0000)
Locations builder should use ConstantLocation() when the
code generator relies on a location to be constant. Code
generator should interrogate locations, not inputs, about
being const.

Change-Id: Ic35bb84aa9f83e0977b151a0430aca6c88f19cf0

compiler/optimizing/code_generator_arm.cc
compiler/optimizing/code_generator_x86.cc

index e30aa6e..54c6cc8 100644 (file)
@@ -2694,7 +2694,7 @@ void LocationsBuilderARM::VisitDiv(HDiv* div) {
     case Primitive::kPrimInt: {
       if (div->InputAt(1)->IsConstant()) {
         locations->SetInAt(0, Location::RequiresRegister());
-        locations->SetInAt(1, Location::RegisterOrConstant(div->InputAt(1)));
+        locations->SetInAt(1, Location::ConstantLocation(div->InputAt(1)->AsConstant()));
         locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
         int32_t abs_imm = std::abs(div->InputAt(1)->AsIntConstant()->GetValue());
         if (abs_imm <= 1) {
@@ -2818,7 +2818,7 @@ void LocationsBuilderARM::VisitRem(HRem* rem) {
     case Primitive::kPrimInt: {
       if (rem->InputAt(1)->IsConstant()) {
         locations->SetInAt(0, Location::RequiresRegister());
-        locations->SetInAt(1, Location::RegisterOrConstant(rem->InputAt(1)));
+        locations->SetInAt(1, Location::ConstantLocation(rem->InputAt(1)->AsConstant()));
         locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
         int32_t abs_imm = std::abs(rem->InputAt(1)->AsIntConstant()->GetValue());
         if (abs_imm <= 1) {
index 8308d9e..cc6f7d3 100644 (file)
@@ -3014,7 +3014,7 @@ void InstructionCodeGeneratorX86::GenerateDivRemIntegral(HBinaryOperation* instr
       DCHECK_EQ(EAX, first.AsRegister<Register>());
       DCHECK_EQ(is_div ? EAX : EDX, out.AsRegister<Register>());
 
-      if (instruction->InputAt(1)->IsIntConstant()) {
+      if (second.IsConstant()) {
         int32_t imm = second.GetConstant()->AsIntConstant()->GetValue();
 
         if (imm == 0) {