summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
author Mark Mendell <mark.p.mendell@intel.com> 2015-11-17 11:16:56 -0500
committer David Brazdil <dbrazdil@google.com> 2015-11-20 16:48:04 +0000
commitf652917de5634b30c974c81d35a72871915b352a (patch)
treec50bcaf37c246df633d42a166334c9b6332e5394 /compiler/optimizing/instruction_simplifier.cc
parent60c4c6ad2b892bb00a6016a147b1cc089ba6bcb5 (diff)
Simplify boolean condition compared to 0
CaffeineMarkRR Logic has some boolean flipping which can be helped by some simplification. Simplify non-FP (A COND_OP B) != 0 to A OPPOSITE_COND_OP B. This is better than the original code, which would use a HBooleanNot after the condition. Also simplify non-FP (A COND_OP B) == 1 to A OPPOSITE_COND_OP B. Move GetOppositeCondition to nodes.h/nodes.cc to share with Boolean Simplification, renaming it to InsertOppositeCondition, as it inserts the new HInstruction (unless it is a constant). Change-Id: I34ded7758836e375de0d6fdba9239d2d451928d0 Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 9ad2dd1c8e..d82b5d2033 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -372,9 +372,8 @@ void InstructionSimplifierVisitor::VisitEqual(HEqual* equal) {
block->RemoveInstruction(equal);
RecordSimplification();
} else if (input_const->AsIntConstant()->IsZero()) {
- // Replace (bool_value == false) with !bool_value
- block->ReplaceAndRemoveInstructionWith(
- equal, new (block->GetGraph()->GetArena()) HBooleanNot(input_value));
+ equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, equal));
+ block->RemoveInstruction(equal);
RecordSimplification();
} else {
// Replace (bool_value == integer_not_zero_nor_one_constant) with false
@@ -399,9 +398,8 @@ void InstructionSimplifierVisitor::VisitNotEqual(HNotEqual* not_equal) {
// We are comparing the boolean to a constant which is of type int and can
// be any constant.
if (input_const->AsIntConstant()->IsOne()) {
- // Replace (bool_value != true) with !bool_value
- block->ReplaceAndRemoveInstructionWith(
- not_equal, new (block->GetGraph()->GetArena()) HBooleanNot(input_value));
+ not_equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, not_equal));
+ block->RemoveInstruction(not_equal);
RecordSimplification();
} else if (input_const->AsIntConstant()->IsZero()) {
// Replace (bool_value != false) with bool_value