summaryrefslogtreecommitdiff
path: root/compiler/optimizing/licm.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2016-01-05 15:55:41 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2016-01-14 15:00:20 +0000
commit15bd22849ee6a1ffb3fb3630f686c2870bdf1bbc (patch)
treea261601589163faa4538bcf1c9d156e8ec4a42b3 /compiler/optimizing/licm.cc
parent5b7b5ddb515828c93f0c2aec67aa513c32d0de22 (diff)
Implement irreducible loop support in optimizing.
So we don't fallback to the interpreter in the presence of irreducible loops. Implications: - A loop pre-header does not necessarily dominate a loop header. - Non-constant redundant phis will be kept in loop headers, to satisfy our linear scan register allocation algorithm. - while-graph optimizations, such as gvn, licm, lse, and dce need to know when they are dealing with irreducible loops. Change-Id: I2cea8934ce0b40162d215353497c7f77d6c9137e
Diffstat (limited to 'compiler/optimizing/licm.cc')
-rw-r--r--compiler/optimizing/licm.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/optimizing/licm.cc b/compiler/optimizing/licm.cc
index 02befc011a..a6b4078f46 100644
--- a/compiler/optimizing/licm.cc
+++ b/compiler/optimizing/licm.cc
@@ -94,6 +94,16 @@ void LICM::Run() {
SideEffects loop_effects = side_effects_.GetLoopEffects(block);
HBasicBlock* pre_header = loop_info->GetPreHeader();
+ bool contains_irreducible_loop = false;
+ if (graph_->HasIrreducibleLoops()) {
+ for (HBlocksInLoopIterator it_loop(*loop_info); !it_loop.Done(); it_loop.Advance()) {
+ if (it_loop.Current()->GetLoopInformation()->IsIrreducible()) {
+ contains_irreducible_loop = true;
+ break;
+ }
+ }
+ }
+
for (HBlocksInLoopIterator it_loop(*loop_info); !it_loop.Done(); it_loop.Advance()) {
HBasicBlock* inner = it_loop.Current();
DCHECK(inner->IsInLoop());
@@ -104,6 +114,12 @@ void LICM::Run() {
}
visited.SetBit(inner->GetBlockId());
+ if (contains_irreducible_loop) {
+ // We cannot licm in an irreducible loop, or in a natural loop containing an
+ // irreducible loop.
+ continue;
+ }
+
// We can move an instruction that can throw only if it is the first
// throwing instruction in the loop. Note that the first potentially
// throwing instruction encountered that is not hoisted stops this