summaryrefslogtreecommitdiff
path: root/compiler/optimizing/ssa_phi_elimination.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2016-01-14 21:25:16 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-01-14 21:25:16 +0000
commit947cb4f5582d1f57270b48d3c47ea95e7f9085b5 (patch)
tree6f6aed8f8cca3177b06521a8db6ca845d18623ad /compiler/optimizing/ssa_phi_elimination.cc
parent7b4199a5fa9f151fbf3af2a34f26d04215a1016c (diff)
parent15bd22849ee6a1ffb3fb3630f686c2870bdf1bbc (diff)
Merge "Implement irreducible loop support in optimizing."
Diffstat (limited to 'compiler/optimizing/ssa_phi_elimination.cc')
-rw-r--r--compiler/optimizing/ssa_phi_elimination.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/optimizing/ssa_phi_elimination.cc b/compiler/optimizing/ssa_phi_elimination.cc
index 2eef307295..6816b6a028 100644
--- a/compiler/optimizing/ssa_phi_elimination.cc
+++ b/compiler/optimizing/ssa_phi_elimination.cc
@@ -154,6 +154,7 @@ void SsaRedundantPhiElimination::Run() {
cycle_worklist.push_back(phi);
visited_phis_in_cycle.insert(phi->GetId());
bool catch_phi_in_cycle = phi->IsCatchPhi();
+ bool irreducible_loop_phi_in_cycle = phi->IsIrreducibleLoopHeaderPhi();
// First do a simple loop over inputs and check if they are all the same.
for (size_t j = 0; j < phi->InputCount(); ++j) {
@@ -187,6 +188,7 @@ void SsaRedundantPhiElimination::Run() {
cycle_worklist.push_back(input->AsPhi());
visited_phis_in_cycle.insert(input->GetId());
catch_phi_in_cycle |= input->AsPhi()->IsCatchPhi();
+ irreducible_loop_phi_in_cycle |= input->IsIrreducibleLoopHeaderPhi();
} else {
// Already visited, nothing to do.
}
@@ -206,6 +208,15 @@ void SsaRedundantPhiElimination::Run() {
continue;
}
+ if (irreducible_loop_phi_in_cycle && !candidate->IsConstant()) {
+ // For irreducible loops, we need to keep the phis to satisfy our linear scan
+ // algorithm.
+ // There is one exception for constants, as the type propagation requires redundant
+ // cyclic phis of a constant to be removed. This is ok for the linear scan as it
+ // has to deal with constants anyway, and they can trivially be rematerialized.
+ continue;
+ }
+
for (HPhi* current : cycle_worklist) {
// The candidate may not dominate a phi in a catch block: there may be non-throwing
// instructions at the beginning of a try range, that may be the first input of