diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-03-31 01:13:53 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-03-31 01:13:53 +0000 |
commit | 8655a539b0192a7a2f9e106e1609e975d92d4b91 (patch) | |
tree | 06bdb2ad47469a95144322d25d4058e6b1e55d8e /lib/Target/X86 | |
parent | adfedb38cd30184427dcd14dfb96acc5c905ca84 (diff) | |
download | external_llvm-8655a539b0192a7a2f9e106e1609e975d92d4b91.zip external_llvm-8655a539b0192a7a2f9e106e1609e975d92d4b91.tar.gz external_llvm-8655a539b0192a7a2f9e106e1609e975d92d4b91.tar.bz2 |
X86 address mode isel tweak. If the base of the address is also used by a CopyToReg (i.e. it's likely live-out), do not fold the sub-expressions into the addressing mode to avoid computing the address twice. The CopyToReg use will be isel'ed to a LEA, re-use it for address instead.
This is not yet enabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86')
-rw-r--r-- | lib/Target/X86/X86ISelDAGToDAG.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index 9caf184..4bc604b 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -41,6 +41,9 @@ #include "llvm/ADT/Statistic.h" using namespace llvm; +#include "llvm/Support/CommandLine.h" +static cl::opt<bool> AvoidDupAddrCompute("x86-avoid-dup-address", cl::Hidden); + STATISTIC(NumLoadMoved, "Number of loads moved below TokenFactor"); //===----------------------------------------------------------------------===// @@ -1035,7 +1038,28 @@ bool X86DAGToDAGISel::SelectAddr(SDValue Op, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp) { X86ISelAddressMode AM; - if (MatchAddress(N, AM)) + bool Done = false; + if (AvoidDupAddrCompute && !N.hasOneUse()) { + unsigned Opcode = N.getOpcode(); + if (Opcode != ISD::Constant && Opcode != ISD::FrameIndex && + Opcode != X86ISD::Wrapper) { + // If we are able to fold N into addressing mode, then we'll allow it even + // if N has multiple uses. In general, addressing computation is used as + // addresses by all of its uses. But watch out for CopyToReg uses, that + // means the address computation is liveout. It will be computed by a LEA + // so we want to avoid computing the address twice. + for (SDNode::use_iterator UI = N.getNode()->use_begin(), + UE = N.getNode()->use_end(); UI != UE; ++UI) { + if (UI->getOpcode() == ISD::CopyToReg) { + MatchAddressBase(N, AM, true, 0); + Done = true; + break; + } + } + } + } + + if (!Done && MatchAddress(N, AM)) return false; MVT VT = N.getValueType(); |