summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Rames <alexandre.rames@arm.com>2015-02-17 15:08:20 +0000
committerAlexandre Rames <alexandre.rames@arm.com>2015-02-17 15:08:20 +0000
commit9341546f1e5177a0328c67c5899ee81d19bd5d88 (patch)
tree80ffb6a99abae69d9a6b1b4ef17ee6d4f68c02d6
parent6e27f82193a8f54cd8ecdc8fb2c4c1adadafbaf4 (diff)
downloadart-9341546f1e5177a0328c67c5899ee81d19bd5d88.tar.gz
art-9341546f1e5177a0328c67c5899ee81d19bd5d88.tar.bz2
art-9341546f1e5177a0328c67c5899ee81d19bd5d88.zip
Opt compiler: ARM64: Optimise floating-point comparison with 0.0.
Change-Id: I297ed92445f20fae2ebf301e90e97772072da364
-rw-r--r--compiler/optimizing/code_generator_arm64.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index ec716a414e..32721e0efc 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -1388,7 +1388,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;
}
@@ -1418,9 +1424,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 {