diff options
Diffstat (limited to 'llvm/lib/CodeGen/IfConversion.cpp')
-rw-r--r-- | llvm/lib/CodeGen/IfConversion.cpp | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index 56a25e0331d..0cac7b71e24 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -588,18 +588,6 @@ bool IfConverter::ValidTriangle(BBInfo &TrueBBI, BBInfo &FalseBBI, return TExit && TExit == FalseBBI.BB; } -/// Increment \p It until it points to a non-debug instruction or to \p End. -/// @param It Iterator to increment -/// @param End Iterator that points to end. Will be compared to It -/// @returns true if It == End, false otherwise. -static inline bool skipDebugInstructionsForward( - MachineBasicBlock::iterator &It, - MachineBasicBlock::iterator &End) { - while (It != End && It->isDebugValue()) - It++; - return It == End; -} - /// Shrink the provided inclusive range by one instruction. /// If the range was one instruction (\p It == \p Begin), It is not modified, /// but \p Empty is set to true. @@ -613,21 +601,6 @@ static inline void shrinkInclusiveRange( It--; } -/// Decrement \p It until it points to a non-debug instruction or the range is -/// empty. -/// @param It Iterator to decrement. -/// @param Begin Iterator that points to beginning. Will be compared to It -/// @param Empty Set to true if the resulting range is Empty -/// @returns the value of Empty as a convenience. -static inline bool skipDebugInstructionsBackward( - MachineBasicBlock::iterator &Begin, - MachineBasicBlock::iterator &It, - bool &Empty) { - while (!Empty && It->isDebugValue()) - shrinkInclusiveRange(Begin, It, Empty); - return Empty; -} - /// Count duplicated instructions and move the iterators to show where they /// are. /// @param TIB True Iterator Begin @@ -659,9 +632,11 @@ bool IfConverter::CountDuplicatedInstructions( while (TIB != TIE && FIB != FIE) { // Skip dbg_value instructions. These do not count. - if(skipDebugInstructionsForward(TIB, TIE)) + TIB = skipDebugInstructionsForward(TIB, TIE); + if(TIB == TIE) break; - if(skipDebugInstructionsForward(FIB, FIE)) + FIB = skipDebugInstructionsForward(FIB, FIE); + if(FIB == FIE) break; if (!TIB->isIdenticalTo(*FIB)) break; @@ -718,9 +693,11 @@ bool IfConverter::CountDuplicatedInstructions( // Count duplicate instructions at the ends of the blocks. while (!TEmpty && !FEmpty) { // Skip dbg_value instructions. These do not count. - if (skipDebugInstructionsBackward(TIB, TIE, TEmpty)) - break; - if (skipDebugInstructionsBackward(FIB, FIE, FEmpty)) + TIE = skipDebugInstructionsBackward(TIE, TIB); + FIE = skipDebugInstructionsBackward(FIE, FIB); + TEmpty = TIE == TIB && TIE->isDebugValue(); + FEmpty = FIE == FIB && FIE->isDebugValue(); + if (TEmpty || FEmpty) break; if (!TIE->isIdenticalTo(*FIE)) break; @@ -770,8 +747,11 @@ static void verifySameBranchInstructions( MachineBasicBlock::iterator E2 = std::prev(MBB2->end()); bool Empty1 = false, Empty2 = false; while (!Empty1 && !Empty2) { - skipDebugInstructionsBackward(B1, E1, Empty1); - skipDebugInstructionsBackward(B2, E2, Empty2); + E1 = skipDebugInstructionsBackward(E1, B1); + E2 = skipDebugInstructionsBackward(E2, B2); + Empty1 = E1 == B1 && E1->isDebugValue(); + Empty2 = E2 == B2 && E2->isDebugValue(); + if (Empty1 && Empty2) break; |