From 5655ec289c3ffd389a02108e2e601b16a9dedbd4 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Fri, 18 Aug 2023 11:47:43 +0100 Subject: An instruction cannot be found before itself If we call FoundBefore with the same instruction in both parameters, we will return true instead of false. By swapping the two ifs inside the for, we can achieve what we want. FoundBefore is used to sort in code sinking, and otherwise we would be not be covering irreflexivity so we wouldn't be having a strict weak ordering. Bug: 296538046 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: I0abab631842ed5e1442437608aaa16c106fe37a8 --- compiler/optimizing/nodes.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 0d78771bf4..2b7e384f34 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1489,12 +1489,12 @@ bool HInstructionList::FoundBefore(const HInstruction* instruction1, const HInstruction* instruction2) const { DCHECK_EQ(instruction1->GetBlock(), instruction2->GetBlock()); for (HInstructionIterator it(*this); !it.Done(); it.Advance()) { - if (it.Current() == instruction1) { - return true; - } if (it.Current() == instruction2) { return false; } + if (it.Current() == instruction1) { + return true; + } } LOG(FATAL) << "Did not find an order between two instructions of the same block."; UNREACHABLE(); -- cgit v1.2.3-59-g8ed1b