diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-10-22 22:48:56 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-10-22 22:48:56 +0000 |
commit | 2bfb32468404eb68dcc1b69a34336794b20e3f33 (patch) | |
tree | d7b5fd2a766a86e0b51f4620681a9a7c5ef7a474 | |
parent | 432a8142ef8efc4978ceb8d257a21240e2d29777 (diff) | |
download | external_llvm-2bfb32468404eb68dcc1b69a34336794b20e3f33.zip external_llvm-2bfb32468404eb68dcc1b69a34336794b20e3f33.tar.gz external_llvm-2bfb32468404eb68dcc1b69a34336794b20e3f33.tar.bz2 |
Be more strict about detecting multi-use blocks for isolation.
When a block has exactly two uses and the register is both live-in and live-out,
don't isolate the block. We would be inserting two copies, so we haven't really
made any progress.
If the live-in and live-out values separate into disconnected components after
splitting, we would be making progress. We can't detect that for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117169 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SplitKit.cpp | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp index 2927114..798f714 100644 --- a/lib/CodeGen/SplitKit.cpp +++ b/lib/CodeGen/SplitKit.cpp @@ -289,34 +289,6 @@ const MachineLoop *SplitAnalysis::getBestSplitLoop() { return Best; } -/// getMultiUseBlocks - if curli has more than one use in a basic block, it -/// may be an advantage to split curli for the duration of the block. -bool SplitAnalysis::getMultiUseBlocks(BlockPtrSet &Blocks) { - // If curli is local to one block, there is no point to splitting it. - if (usingBlocks_.size() <= 1) - return false; - // Add blocks with multiple uses. - for (BlockCountMap::iterator I = usingBlocks_.begin(), E = usingBlocks_.end(); - I != E; ++I) - switch (I->second) { - case 0: - case 1: - continue; - case 2: { - // It doesn't pay to split a 2-instr block if it redefines curli. - VNInfo *VN1 = curli_->getVNInfoAt(lis_.getMBBStartIdx(I->first)); - VNInfo *VN2 = - curli_->getVNInfoAt(lis_.getMBBEndIdx(I->first).getPrevIndex()); - // live-in and live-out with a different value. - if (VN1 && VN2 && VN1 != VN2) - continue; - } // Fall through. - default: - Blocks.insert(I->first); - } - return !Blocks.empty(); -} - //===----------------------------------------------------------------------===// // LiveIntervalMap //===----------------------------------------------------------------------===// @@ -946,6 +918,35 @@ void SplitEditor::splitAroundLoop(const MachineLoop *Loop) { // Single Block Splitting //===----------------------------------------------------------------------===// +/// getMultiUseBlocks - if curli has more than one use in a basic block, it +/// may be an advantage to split curli for the duration of the block. +bool SplitAnalysis::getMultiUseBlocks(BlockPtrSet &Blocks) { + // If curli is local to one block, there is no point to splitting it. + if (usingBlocks_.size() <= 1) + return false; + // Add blocks with multiple uses. + for (BlockCountMap::iterator I = usingBlocks_.begin(), E = usingBlocks_.end(); + I != E; ++I) + switch (I->second) { + case 0: + case 1: + continue; + case 2: { + // When there are only two uses and curli is both live in and live out, + // we don't really win anything by isolating the block since we would be + // inserting two copies. + // The remaing register would still have two uses in the block. (Unless it + // separates into disconnected components). + if (lis_.isLiveInToMBB(*curli_, I->first) && + lis_.isLiveOutOfMBB(*curli_, I->first)) + continue; + } // Fall through. + default: + Blocks.insert(I->first); + } + return !Blocks.empty(); +} + /// splitSingleBlocks - Split curli into a separate live interval inside each /// basic block in Blocks. void SplitEditor::splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks) { |