ART: Implement HSelect
This patch adds a new HIR instruction to Optimizing. HSelect returns
one of two inputs based on the outcome of a condition.
This is only initial implementation which:
- defines the new instruction,
- repurposes BooleanSimplifier to emit it,
- extends InstructionSimplifier to statically resolve it,
- updates existing code and tests accordingly.
Code generators currently emit fallback if/then/else code and will be
updated in follow-up CLs to use platform-specific conditional moves
when possible.
Change-Id: Ib61b17146487ebe6b55350c2b589f0b971dcaaee
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index 3113677..962e77d 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -859,8 +859,12 @@
value));
}
} else if (input->GetType() == Primitive::kPrimInt
- && (input->IsPhi() || input->IsAnd() || input->IsOr() || input->IsXor())) {
- // TODO: We need a data-flow analysis to determine if the Phi or
+ && (input->IsPhi() ||
+ input->IsAnd() ||
+ input->IsOr() ||
+ input->IsXor() ||
+ input->IsSelect())) {
+ // TODO: We need a data-flow analysis to determine if the Phi or Select or
// binary operation is actually Boolean. Allow for now.
} else if (input->GetType() != Primitive::kPrimBoolean) {
AddError(StringPrintf(
@@ -893,6 +897,11 @@
HandleBooleanInput(instruction, 0);
}
+void SSAChecker::VisitSelect(HSelect* instruction) {
+ VisitInstruction(instruction);
+ HandleBooleanInput(instruction, 2);
+}
+
void SSAChecker::VisitBooleanNot(HBooleanNot* instruction) {
VisitInstruction(instruction);
HandleBooleanInput(instruction, 0);