summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-10 01:23:55 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-10 01:23:55 +0000
commitaa06de2447d73a6e6b4b30c1b61a2695a2e9669a (patch)
tree5ba1b5ae3107ae59d21aa9889fc77b2a3777c971 /llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
parent933693b6218327d9c2c75b86061f6808fdb4cdc0 (diff)
downloadbcm5719-llvm-aa06de2447d73a6e6b4b30c1b61a2695a2e9669a.tar.gz
bcm5719-llvm-aa06de2447d73a6e6b4b30c1b61a2695a2e9669a.zip
Optimize LiveIntervals::intervalIsInOneMBB().
No looping and binary searches necessary. Return a pointer to the containing block instead of just a bool. llvm-svn: 150218
Diffstat (limited to 'llvm/lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveIntervalAnalysis.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
index 1d5e3b1be75..7655cf5e930 100644
--- a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -1086,23 +1086,28 @@ LiveIntervals::isReMaterializable(const LiveInterval &li,
return true;
}
-bool LiveIntervals::intervalIsInOneMBB(const LiveInterval &li) const {
- LiveInterval::Ranges::const_iterator itr = li.ranges.begin();
-
- MachineBasicBlock *mbb = indexes_->getMBBCoveringRange(itr->start, itr->end);
-
- if (mbb == 0)
- return false;
-
- for (++itr; itr != li.ranges.end(); ++itr) {
- MachineBasicBlock *mbb2 =
- indexes_->getMBBCoveringRange(itr->start, itr->end);
-
- if (mbb2 != mbb)
- return false;
- }
-
- return true;
+MachineBasicBlock*
+LiveIntervals::intervalIsInOneMBB(const LiveInterval &LI) const {
+ // A local live range must be fully contained inside the block, meaning it is
+ // defined and killed at instructions, not at block boundaries. It is not
+ // live in or or out of any block.
+ //
+ // It is technically possible to have a PHI-defined live range identical to a
+ // single block, but we are going to return false in that case.
+
+ SlotIndex Start = LI.beginIndex();
+ if (Start.isBlock())
+ return NULL;
+
+ SlotIndex Stop = LI.endIndex();
+ if (Stop.isBlock())
+ return NULL;
+
+ // getMBBFromIndex doesn't need to search the MBB table when both indexes
+ // belong to proper instructions.
+ MachineBasicBlock *MBB1 = indexes_->getMBBFromIndex(Start);
+ MachineBasicBlock *MBB2 = indexes_->getMBBFromIndex(Stop);
+ return MBB1 == MBB2 ? MBB1 : NULL;
}
float
OpenPOWER on IntegriCloud