summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveInterval.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-20 06:06:30 +0000
committerChris Lattner <sabre@nondot.org>2005-10-20 06:06:30 +0000
commitf5ce2678f63f5776fddcfc34ae63ecdec622938c (patch)
treead511701269c3439a77c1dd9891321f3e30e1d11 /lib/CodeGen/LiveInterval.cpp
parent1e9f3af561932b324c45c05ff9a8728143e90753 (diff)
downloadllvm-f5ce2678f63f5776fddcfc34ae63ecdec622938c.tar.gz
llvm-f5ce2678f63f5776fddcfc34ae63ecdec622938c.tar.bz2
llvm-f5ce2678f63f5776fddcfc34ae63ecdec622938c.tar.xz
Refactor some code, pulling it out into a function. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23839 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveInterval.cpp')
-rw-r--r--lib/CodeGen/LiveInterval.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
index 2cbb46b082..93d32d8edb 100644
--- a/lib/CodeGen/LiveInterval.cpp
+++ b/lib/CodeGen/LiveInterval.cpp
@@ -101,6 +101,29 @@ bool LiveInterval::overlapsFrom(const LiveInterval& other,
return false;
}
+/// NontrivialOverlap - Check to see if the two live ranges specified by i and j
+/// overlap. If so, check to see if they have value numbers that are not
+/// iIdx/jIdx respectively. If both conditions are true, return true.
+static inline bool NontrivialOverlap(LiveInterval::Ranges::const_iterator i,
+ LiveInterval::Ranges::const_iterator j,
+ unsigned iIdx, unsigned jIdx) {
+ if (i->start == j->start) {
+ // If this is not the allowed value merge, we cannot join.
+ if (i->ValId != iIdx || j->ValId != jIdx)
+ return true;
+ } else if (i->start < j->start) {
+ if (i->end > j->start && i->ValId != iIdx || j->ValId != jIdx) {
+ return true;
+ }
+ } else {
+ if (j->end > i->start &&
+ i->ValId != iIdx || j->ValId != jIdx)
+ return true;
+ }
+
+ return false;
+}
+
/// joinable - Two intervals are joinable if the either don't overlap at all
/// or if the destination of the copy is a single assignment value, and it
/// only overlaps with one value in the source interval.
@@ -125,21 +148,9 @@ bool LiveInterval::joinable(const LiveInterval &other, unsigned CopyIdx) const {
}
while (i != ie && j != je) {
- if (i->start == j->start) {
- // If this is not the allowed value merge, we cannot join.
- if (i->ValId != ThisValIdx || j->ValId != OtherValIdx)
- return false;
- } else if (i->start < j->start) {
- if (i->end > j->start) {
- if (i->ValId != ThisValIdx || j->ValId != OtherValIdx)
- return false;
- }
- } else {
- if (j->end > i->start) {
- if (i->ValId != ThisValIdx || j->ValId != OtherValIdx)
- return false;
- }
- }
+ if (NontrivialOverlap(i, j, ThisValIdx, OtherValIdx))
+ return false;
+
if (i->end < j->end)
++i;
else