From 543406a69b339e875c39c75f3935e27fedefc0a7 Mon Sep 17 00:00:00 2001 From: David Green Date: Mon, 24 May 2021 12:22:15 +0100 Subject: [ARM] Allow findLoopPreheader to return headers with multiple loop successors The findLoopPreheader function will currently not find a preheader if it branches to multiple different loop headers. This patch adds an option to relax that, allowing ARMLowOverheadLoops to process more loops successfully. This helps with WhileLoopStart setup instructions that can branch/fallthrough to the low overhead loop and to branch to a separate loop from the same preheader (but I don't believe it is possible for both loops to be low overhead loops). Differential Revision: https://reviews.llvm.org/D102747 --- llvm/lib/CodeGen/MachineLoopInfo.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'llvm/lib/CodeGen/MachineLoopInfo.cpp') diff --git a/llvm/lib/CodeGen/MachineLoopInfo.cpp b/llvm/lib/CodeGen/MachineLoopInfo.cpp index 78480d0..8f91a5b 100644 --- a/llvm/lib/CodeGen/MachineLoopInfo.cpp +++ b/llvm/lib/CodeGen/MachineLoopInfo.cpp @@ -115,8 +115,8 @@ DebugLoc MachineLoop::getStartLoc() const { } MachineBasicBlock * -MachineLoopInfo::findLoopPreheader(MachineLoop *L, - bool SpeculativePreheader) const { +MachineLoopInfo::findLoopPreheader(MachineLoop *L, bool SpeculativePreheader, + bool FindMultiLoopPreheader) const { if (MachineBasicBlock *PB = L->getLoopPreheader()) return PB; @@ -139,12 +139,14 @@ MachineLoopInfo::findLoopPreheader(MachineLoop *L, // Check if the preheader candidate is a successor of any other loop // headers. We want to avoid having two loop setups in the same block. - for (MachineBasicBlock *S : Preheader->successors()) { - if (S == HB) - continue; - MachineLoop *T = getLoopFor(S); - if (T && T->getHeader() == S) - return nullptr; + if (!FindMultiLoopPreheader) { + for (MachineBasicBlock *S : Preheader->successors()) { + if (S == HB) + continue; + MachineLoop *T = getLoopFor(S); + if (T && T->getHeader() == S) + return nullptr; + } } return Preheader; } -- cgit v1.1