From 73f1f3be46652d3f6df61b4234c366ebbf81274a Mon Sep 17 00:00:00 2001 From: Aart Bik Date: Wed, 28 Oct 2015 15:28:08 -0700 Subject: Move loop invariant utility to more general place. Change-Id: I15ebfbf9684f0fcce9e63d078ff8dc1381fd1ca3 --- compiler/optimizing/nodes.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 348026551e..8b28ff91d4 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -574,6 +574,17 @@ bool HLoopInformation::IsIn(const HLoopInformation& other) const { return other.blocks_.IsBitSet(header_->GetBlockId()); } +bool HLoopInformation::IsLoopInvariant(HInstruction* instruction, bool must_dominate) const { + HLoopInformation* other_loop = instruction->GetBlock()->GetLoopInformation(); + if (other_loop != this && (other_loop == nullptr || !other_loop->IsIn(*this))) { + if (must_dominate) { + return instruction->GetBlock()->Dominates(GetHeader()); + } + return true; + } + return false; +} + size_t HLoopInformation::GetLifetimeEnd() const { size_t last_position = 0; for (HBasicBlock* back_edge : GetBackEdges()) { -- cgit v1.2.3-59-g8ed1b