summaryrefslogtreecommitdiff
path: root/compiler/optimizing/superblock_cloner.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2019-04-29 10:55:09 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2019-04-30 09:49:17 +0000
commit256c94b568f35f8f23feaaf9ea0d64ed1edab1d4 (patch)
tree1f03dfa6f05ee6d4fc2c0a534ff8b5d5031c80cc /compiler/optimizing/superblock_cloner.cc
parent7711c35fa603b86d520991c4e97ca297add81881 (diff)
Update induction ranges in superblock cloner.
Because loop unrolling is part of a general loop optimization pass, it needs to update induction ranges as it will invalidate its instruction cache with new instructions. Bug: 131174583 Test: 696-loop Change-Id: Id3628efe316b58f69abbd9ebd43e891a8e42529f
Diffstat (limited to 'compiler/optimizing/superblock_cloner.cc')
-rw-r--r--compiler/optimizing/superblock_cloner.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler/optimizing/superblock_cloner.cc b/compiler/optimizing/superblock_cloner.cc
index 878967cc6e..dc433feb51 100644
--- a/compiler/optimizing/superblock_cloner.cc
+++ b/compiler/optimizing/superblock_cloner.cc
@@ -17,6 +17,7 @@
#include "superblock_cloner.h"
#include "common_dominator.h"
+#include "induction_var_range.h"
#include "graph_checker.h"
#include <iostream>
@@ -556,6 +557,13 @@ bool SuperblockCloner::CollectLiveOutsAndCheckClonable(HInstructionMap* live_out
return true;
}
+void SuperblockCloner::UpdateInductionRangeInfoOf(
+ HInstruction* user, HInstruction* old_instruction, HInstruction* replacement) {
+ if (induction_range_ != nullptr) {
+ induction_range_->Replace(user, old_instruction, replacement);
+ }
+}
+
void SuperblockCloner::ConstructSubgraphClosedSSA() {
if (live_outs_.empty()) {
return;
@@ -599,6 +607,7 @@ void SuperblockCloner::ConstructSubgraphClosedSSA() {
++it;
if (!IsInOrigBBSet(user->GetBlock())) {
user->ReplaceInput(phi, index);
+ UpdateInductionRangeInfoOf(user, value, phi);
}
}
@@ -776,7 +785,8 @@ void SuperblockCloner::DumpInputSets() {
SuperblockCloner::SuperblockCloner(HGraph* graph,
const HBasicBlockSet* orig_bb_set,
HBasicBlockMap* bb_map,
- HInstructionMap* hir_map)
+ HInstructionMap* hir_map,
+ InductionVarRange* induction_range)
: graph_(graph),
arena_(graph->GetAllocator()),
orig_bb_set_(arena_, orig_bb_set->GetSizeOf(), true, kArenaAllocSuperblockCloner),
@@ -785,6 +795,7 @@ SuperblockCloner::SuperblockCloner(HGraph* graph,
remap_incoming_(nullptr),
bb_map_(bb_map),
hir_map_(hir_map),
+ induction_range_(induction_range),
outer_loop_(nullptr),
outer_loop_bb_set_(arena_, orig_bb_set->GetSizeOf(), true, kArenaAllocSuperblockCloner),
live_outs_(std::less<HInstruction*>(),
@@ -1078,7 +1089,8 @@ HLoopInformation* FindCommonLoop(HLoopInformation* loop1, HLoopInformation* loop
}
bool PeelUnrollHelper::IsLoopClonable(HLoopInformation* loop_info) {
- PeelUnrollHelper helper(loop_info, nullptr, nullptr);
+ PeelUnrollHelper helper(
+ loop_info, /* bb_map= */ nullptr, /* hir_map= */ nullptr, /* induction_range= */ nullptr);
return helper.IsLoopClonable();
}
@@ -1119,12 +1131,13 @@ HBasicBlock* PeelUnrollHelper::DoPeelUnrollImpl(bool to_unroll) {
return loop_header;
}
-PeelUnrollSimpleHelper::PeelUnrollSimpleHelper(HLoopInformation* info)
+PeelUnrollSimpleHelper::PeelUnrollSimpleHelper(HLoopInformation* info,
+ InductionVarRange* induction_range)
: bb_map_(std::less<HBasicBlock*>(),
info->GetHeader()->GetGraph()->GetAllocator()->Adapter(kArenaAllocSuperblockCloner)),
hir_map_(std::less<HInstruction*>(),
info->GetHeader()->GetGraph()->GetAllocator()->Adapter(kArenaAllocSuperblockCloner)),
- helper_(info, &bb_map_, &hir_map_) {}
+ helper_(info, &bb_map_, &hir_map_, induction_range) {}
} // namespace art