[llvm-commits] [llvm] r121871 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Wed Dec 15 09:49:53 PST 2010
Author: stoklund
Date: Wed Dec 15 11:49:52 2010
New Revision: 121871
URL: http://llvm.org/viewvc/llvm-project?rev=121871&view=rev
Log:
Detect and enumerate bypass loops.
Bypass loops have the current live range live through, but contain no uses or
defs. Splitting around a bypass loop can free registers for other uses inside
the loop by spilling the split range.
Modified:
llvm/trunk/lib/CodeGen/SplitKit.cpp
llvm/trunk/lib/CodeGen/SplitKit.h
Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=121871&r1=121870&r2=121871&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SplitKit.cpp (original)
+++ llvm/trunk/lib/CodeGen/SplitKit.cpp Wed Dec 15 11:49:52 2010
@@ -325,6 +325,36 @@
return Best;
}
+/// isBypassLoop - Return true if curli is live through Loop and has no uses
+/// inside the loop. Bypass loops are candidates for splitting because it can
+/// prevent interference inside the loop.
+bool SplitAnalysis::isBypassLoop(const MachineLoop *Loop) {
+ // If curli is live into the loop header and there are no uses in the loop, it
+ // must be live in the entire loop and live on at least one exiting edge.
+ return !usingLoops_.count(Loop) &&
+ lis_.isLiveInToMBB(*curli_, Loop->getHeader());
+}
+
+/// getBypassLoops - Get all the maximal bypass loops. These are the bypass
+/// loops whose parent is not a bypass loop.
+void SplitAnalysis::getBypassLoops(LoopPtrSet &BypassLoops) {
+ SmallVector<MachineLoop*, 8> Todo(loops_.begin(), loops_.end());
+ while (!Todo.empty) {
+ MachineLoop *Loop = Todo.pop_back_val();
+ if (!usingLoops_.count(Loop)) {
+ // This is either a bypass loop or completely irrelevant.
+ if (lis_.isLiveInToMBB(*curli_, Loop->getHeader()))
+ BypassLoops.insert(Loop);
+ // Either way, skip the child loops.
+ continue;
+ }
+
+ // The child loops may be bypass loops.
+ Todo.append(Loop->begin(), Loop->end());
+ }
+}
+
+
//===----------------------------------------------------------------------===//
// LiveIntervalMap
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/CodeGen/SplitKit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=121871&r1=121870&r2=121871&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SplitKit.h (original)
+++ llvm/trunk/lib/CodeGen/SplitKit.h Wed Dec 15 11:49:52 2010
@@ -141,6 +141,15 @@
/// separate register, or NULL.
const MachineLoop *getBestSplitLoop();
+ /// isBypassLoop - Return true if curli is live through Loop and has no uses
+ /// inside the loop. Bypass loops are candidates for splitting because it can
+ /// prevent interference inside the loop.
+ bool isBypassLoop(const MachineLoop *Loop);
+
+ /// getBypassLoops - Get all the maximal bypass loops. These are the bypass
+ /// loops whose parent is not a bypass loop.
+ void getBypassLoops(LoopPtrSet&);
+
/// getMultiUseBlocks - Add basic blocks to Blocks that may benefit from
/// having curli split to a new live interval. Return true if Blocks can be
/// passed to SplitEditor::splitSingleBlocks.
More information about the llvm-commits
mailing list