From c4b6a789809696c2835999d39293466c99f22c1a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 11 Jan 2005 22:29:12 +0000 Subject: [PATCH] Treat int constants as not requiring a register, since they are almost always folded into an instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19486 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelPattern.cpp | 36 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp index caef663d7b6..5aa2927f486 100644 --- a/lib/Target/X86/X86ISelPattern.cpp +++ b/lib/Target/X86/X86ISelPattern.cpp @@ -388,22 +388,30 @@ unsigned ISel::ComputeRegPressure(SDOperand O) { // FIXME: Should operations like CALL (which clobber lots o regs) have a // higher fixed cost?? - if (N->getNumOperands() == 0) - return Result = 1; - - unsigned MaxRegUse = 0; - unsigned NumExtraMaxRegUsers = 0; - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { - unsigned Regs = ComputeRegPressure(N->getOperand(i)); - if (Regs > MaxRegUse) { - MaxRegUse = Regs; - NumExtraMaxRegUsers = 0; - } else if (Regs == MaxRegUse) { - ++NumExtraMaxRegUsers; + if (N->getNumOperands() == 0) { + Result = 1; + } else { + unsigned MaxRegUse = 0; + unsigned NumExtraMaxRegUsers = 0; + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + unsigned Regs; + if (N->getOperand(i).getOpcode() == ISD::Constant) + Regs = 0; + else + Regs = ComputeRegPressure(N->getOperand(i)); + if (Regs > MaxRegUse) { + MaxRegUse = Regs; + NumExtraMaxRegUsers = 0; + } else if (Regs == MaxRegUse && + N->getOperand(i).getValueType() != MVT::Other) { + ++NumExtraMaxRegUsers; + } } - } - return Result = MaxRegUse+NumExtraMaxRegUsers; + Result = MaxRegUse+NumExtraMaxRegUsers; + } + std::cerr << " WEIGHT: " << Result << " "; N->dump(); std::cerr << "\n"; + return Result; } /// SelectAddress - Add the specified node to the specified addressing mode, -- 2.34.1