From 604c6e4764edb2fd244e9f47626868cda5644a7a Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 17 Sep 2014 12:08:44 +0100 Subject: Ensure the first predecessor of a loop is the pre header. Note that the check in ssa_phi_elimination.cc was very defensive: it does not affect the outcome of the algorithm whether the loop phi takes itself as the first input. It makes things consistent to always have the pre header as first input. Change-Id: Ic86248c1f38af67f7432782f6deefae1f4bf1ab6 --- compiler/optimizing/nodes.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/optimizing/nodes.h') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index d6dfeaede8..142b517ea2 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -331,6 +331,13 @@ class HBasicBlock : public ArenaObject { block->successors_.Add(this); } + void SwapPredecessors() { + DCHECK(predecessors_.Size() == 2); + HBasicBlock* temp = predecessors_.Get(0); + predecessors_.Put(0, predecessors_.Get(1)); + predecessors_.Put(1, temp); + } + size_t GetPredecessorIndexOf(HBasicBlock* predecessor) { for (size_t i = 0, e = predecessors_.Size(); i < e; ++i) { if (predecessors_.Get(i) == predecessor) { -- cgit v1.2.3-59-g8ed1b