From 11330f7526ef11109ca31aa1abbb4f9a698cd95a Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 12 Oct 2007 09:15:53 +0000 Subject: [PATCH] Restrict EXTRACT_SUBREG coalescing to avoid negative performance impact. llvm-svn: 42903 --- llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp index 9d43750f1c68..67e829efee18 100644 --- a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -264,8 +264,13 @@ bool SimpleRegisterCoalescing::JoinCopy(MachineInstr *CopyMI, if (li_->hasInterval(*SR) && RHS.overlaps(li_->getInterval(*SR))) { DOUT << "Interfere with sub-register "; DEBUG(li_->getInterval(*SR).print(DOUT, mri_)); - return true; + return true; // Not coalescable } + } else if (li_->getInterval(repDstReg).getSize() > + li_->getInterval(repSrcReg).getSize()) { + // Be conservative. If both sides are virtual registers, do not coalesce + // if the sub-register live interval is longer. + return false; } } else if (differingRegisterClasses(repSrcReg, repDstReg)) { // If they are not of the same register class, we cannot join them.