diff options
author | Roland Levillain <rpl@google.com> | 2015-02-20 11:21:28 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-02-20 11:21:30 +0000 |
commit | 1382e569b31f4fab61fcfca5aa93275a2a3cb757 (patch) | |
tree | b093c19c98c0cf397cda84a1fcb30dbf4ed8fc0c | |
parent | 4fe292e2b6ba3980605373f183055a374084c65b (diff) | |
parent | 9341546f1e5177a0328c67c5899ee81d19bd5d88 (diff) | |
download | art-1382e569b31f4fab61fcfca5aa93275a2a3cb757.tar.gz art-1382e569b31f4fab61fcfca5aa93275a2a3cb757.tar.bz2 art-1382e569b31f4fab61fcfca5aa93275a2a3cb757.zip |
Merge "Opt compiler: ARM64: Optimise floating-point comparison with 0.0."
-rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 8220207b6c..0bc150630c 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -1397,7 +1397,13 @@ void LocationsBuilderARM64::VisitCompare(HCompare* compare) { case Primitive::kPrimFloat: case Primitive::kPrimDouble: { locations->SetInAt(0, Location::RequiresFpuRegister()); - locations->SetInAt(1, Location::RequiresFpuRegister()); + HInstruction* right = compare->InputAt(1); + if ((right->IsFloatConstant() && (right->AsFloatConstant()->GetValue() == 0.0f)) || + (right->IsDoubleConstant() && (right->AsDoubleConstant()->GetValue() == 0.0))) { + locations->SetInAt(1, Location::ConstantLocation(right->AsConstant())); + } else { + locations->SetInAt(1, Location::RequiresFpuRegister()); + } locations->SetOut(Location::RequiresRegister()); break; } @@ -1427,9 +1433,17 @@ void InstructionCodeGeneratorARM64::VisitCompare(HCompare* compare) { case Primitive::kPrimDouble: { Register result = OutputRegister(compare); FPRegister left = InputFPRegisterAt(compare, 0); - FPRegister right = InputFPRegisterAt(compare, 1); - - __ Fcmp(left, right); + if (compare->GetLocations()->InAt(1).IsConstant()) { + if (kIsDebugBuild) { + HInstruction* right = compare->GetLocations()->InAt(1).GetConstant(); + DCHECK((right->IsFloatConstant() && (right->AsFloatConstant()->GetValue() == 0.0f)) || + (right->IsDoubleConstant() && (right->AsDoubleConstant()->GetValue() == 0.0))); + } + // 0.0 is the only immediate that can be encoded directly in a FCMP instruction. + __ Fcmp(left, 0.0); + } else { + __ Fcmp(left, InputFPRegisterAt(compare, 1)); + } if (compare->IsGtBias()) { __ Cset(result, ne); } else { |