diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 1 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 1 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 1 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 1 | ||||
| -rw-r--r-- | compiler/optimizing/graph_checker.cc | 32 | ||||
| -rw-r--r-- | compiler/optimizing/graph_checker.h | 3 |
6 files changed, 26 insertions, 13 deletions
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index 507b3cd021..2ea920310a 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -2673,7 +2673,6 @@ void LocationsBuilderARM::VisitBooleanNot(HBooleanNot* bool_not) { } void InstructionCodeGeneratorARM::VisitBooleanNot(HBooleanNot* bool_not) { - DCHECK_EQ(bool_not->InputAt(0)->GetType(), Primitive::kPrimBoolean); LocationSummary* locations = bool_not->GetLocations(); Location out = locations->Out(); Location in = locations->InAt(0); diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index f6ec729560..efc41e7c06 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -2286,7 +2286,6 @@ void LocationsBuilderARM64::VisitBooleanNot(HBooleanNot* instruction) { } void InstructionCodeGeneratorARM64::VisitBooleanNot(HBooleanNot* instruction) { - DCHECK_EQ(instruction->InputAt(0)->GetType(), Primitive::kPrimBoolean); __ Eor(OutputRegister(instruction), InputRegisterAt(instruction, 0), vixl::Operand(1)); } diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 0cc377cf03..879216d59b 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -2931,7 +2931,6 @@ void LocationsBuilderX86::VisitBooleanNot(HBooleanNot* bool_not) { } void InstructionCodeGeneratorX86::VisitBooleanNot(HBooleanNot* bool_not) { - DCHECK_EQ(bool_not->InputAt(0)->GetType(), Primitive::kPrimBoolean); LocationSummary* locations = bool_not->GetLocations(); Location in = locations->InAt(0); Location out = locations->Out(); diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index fb0f4ca06c..a3d3490357 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -2986,7 +2986,6 @@ void LocationsBuilderX86_64::VisitBooleanNot(HBooleanNot* bool_not) { } 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()); diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index 7c3c2bf03d..906c8e8c76 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -369,26 +369,40 @@ void SSAChecker::VisitPhi(HPhi* phi) { } } -void SSAChecker::VisitIf(HIf* instruction) { - VisitInstruction(instruction); - HInstruction* input = instruction->InputAt(0); +void SSAChecker::HandleBooleanInput(HInstruction* instruction, size_t input_index) { + HInstruction* input = instruction->InputAt(input_index); if (input->IsIntConstant()) { - int value = input->AsIntConstant()->GetValue(); + int32_t value = input->AsIntConstant()->GetValue(); if (value != 0 && value != 1) { AddError(StringPrintf( - "If instruction %d has a non-Boolean constant input " - "whose value is: %d.", + "%s instruction %d has a non-Boolean constant input %d whose value is: %d.", + instruction->DebugName(), instruction->GetId(), + static_cast<int>(input_index), value)); } - } else if (instruction->InputAt(0)->GetType() != Primitive::kPrimBoolean) { + } else if (input->GetType() == Primitive::kPrimInt && input->IsPhi()) { + // TODO: We need a data-flow analysis which determines if the Phi is boolean. + } else if (input->GetType() != Primitive::kPrimBoolean) { AddError(StringPrintf( - "If instruction %d has a non-Boolean input type: %s.", + "%s instruction %d has a non-Boolean input %d whose type is: %s.", + instruction->DebugName(), instruction->GetId(), - Primitive::PrettyDescriptor(instruction->InputAt(0)->GetType()))); + static_cast<int>(input_index), + Primitive::PrettyDescriptor(input->GetType()))); } } +void SSAChecker::VisitIf(HIf* instruction) { + VisitInstruction(instruction); + HandleBooleanInput(instruction, 0); +} + +void SSAChecker::VisitBooleanNot(HBooleanNot* instruction) { + VisitInstruction(instruction); + HandleBooleanInput(instruction, 0); +} + void SSAChecker::VisitCondition(HCondition* op) { VisitInstruction(op); if (op->GetType() != Primitive::kPrimBoolean) { diff --git a/compiler/optimizing/graph_checker.h b/compiler/optimizing/graph_checker.h index 89fea0a07f..4568a5ef9d 100644 --- a/compiler/optimizing/graph_checker.h +++ b/compiler/optimizing/graph_checker.h @@ -107,8 +107,11 @@ class SSAChecker : public GraphChecker { void VisitBinaryOperation(HBinaryOperation* op) OVERRIDE; void VisitCondition(HCondition* op) OVERRIDE; void VisitIf(HIf* instruction) OVERRIDE; + void VisitBooleanNot(HBooleanNot* instruction) OVERRIDE; void VisitConstant(HConstant* instruction) OVERRIDE; + void HandleBooleanInput(HInstruction* instruction, size_t input_index); + private: DISALLOW_COPY_AND_ASSIGN(SSAChecker); }; |