RFC: Generate select instruction for conditional returns.
The select generator currently only inserts select instructions
if there is a diamond shape with a phi.
This change extends the select generator to also deal with the
pattern:
if (condition) {
movable instruction 0
return value0
} else {
movable instruction 1
return value1
}
which it turns into:
moveable instruction 0
moveable instruction 1
return select (value0, value1, condition)
Test: 592-checker-regression-bool-input
Change-Id: Iac50fb181dc2c9b7619f28977298662bc09fc0e1
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index ddd798b..de4dc06 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -1745,6 +1745,10 @@
return HasOnlyOneInstruction(*this) && GetLastInstruction()->IsGoto();
}
+bool HBasicBlock::IsSingleReturn() const {
+ return HasOnlyOneInstruction(*this) && GetLastInstruction()->IsReturn();
+}
+
bool HBasicBlock::IsSingleTryBoundary() const {
return HasOnlyOneInstruction(*this) && GetLastInstruction()->IsTryBoundary();
}