summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/code_generator_x86_64.cc
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2015-04-03 16:02:44 +0100
committerDavid Brazdil <dbrazdil@google.com>2015-04-15 12:51:49 +0100
commit66d126ea06ce3f507d86ca5f0d1f752170ac9be1 (patch)
tree8e247db17ef085b55725b21c64d292414fd00b32 /compiler/optimizing/code_generator_x86_64.cc
parent9bb3e8e10d7d9230a323511094a9e260062a1473 (diff)
downloadart-66d126ea06ce3f507d86ca5f0d1f752170ac9be1.tar.gz
art-66d126ea06ce3f507d86ca5f0d1f752170ac9be1.tar.bz2
art-66d126ea06ce3f507d86ca5f0d1f752170ac9be1.zip
ART: Implement HBooleanNot instruction
Optimizations simplifying operations on boolean values (boolean simplifier, instruction simplifier) can benefit from having a special HInstruction for negating booleans in order to perform more transforms and produce faster machine code. This patch implements HBooleanNot as 'x xor 1', assuming that booleans are 1-bit integers and allowing for a single-instruction negation on all supported platforms. Change-Id: I33a2649c1821255b18a86ca68ed16416063c739f
Diffstat (limited to 'compiler/optimizing/code_generator_x86_64.cc')
-rw-r--r--compiler/optimizing/code_generator_x86_64.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index 7a928d4d7d..0dd44239ef 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -2974,6 +2974,22 @@ void InstructionCodeGeneratorX86_64::VisitNot(HNot* not_) {
}
}
+void LocationsBuilderX86_64::VisitBooleanNot(HBooleanNot* bool_not) {
+ LocationSummary* locations =
+ new (GetGraph()->GetArena()) LocationSummary(bool_not, LocationSummary::kNoCall);
+ locations->SetInAt(0, Location::RequiresRegister());
+ locations->SetOut(Location::SameAsFirstInput());
+}
+
+void InstructionCodeGeneratorX86_64::VisitBooleanNot(HBooleanNot* bool_not) {
+ DCHECK_EQ(bool_not->InputAt(0)->GetType(), Primitive::kPrimBoolean);
+ LocationSummary* locations = bool_not->GetLocations();
+ DCHECK_EQ(locations->InAt(0).AsRegister<CpuRegister>().AsRegister(),
+ locations->Out().AsRegister<CpuRegister>().AsRegister());
+ Location out = locations->Out();
+ __ xorl(out.AsRegister<CpuRegister>(), Immediate(1));
+}
+
void LocationsBuilderX86_64::VisitPhi(HPhi* instruction) {
LocationSummary* locations =
new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);