From 256c94b568f35f8f23feaaf9ea0d64ed1edab1d4 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 29 Apr 2019 10:55:09 +0100 Subject: 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 --- compiler/optimizing/superblock_cloner.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'compiler/optimizing/superblock_cloner.cc') 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 @@ -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(), @@ -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(), info->GetHeader()->GetGraph()->GetAllocator()->Adapter(kArenaAllocSuperblockCloner)), hir_map_(std::less(), info->GetHeader()->GetGraph()->GetAllocator()->Adapter(kArenaAllocSuperblockCloner)), - helper_(info, &bb_map_, &hir_map_) {} + helper_(info, &bb_map_, &hir_map_, induction_range) {} } // namespace art -- cgit v1.2.3-59-g8ed1b