2010-04-17 07:04:22 +08:00
|
|
|
//===-- X86SelectionDAGInfo.cpp - X86 SelectionDAG Info -------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-04-17 07:04:22 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the X86SelectionDAGInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "X86SelectionDAGInfo.h"
|
2014-06-07 07:26:43 +08:00
|
|
|
#include "X86ISelLowering.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "X86InstrInfo.h"
|
2014-06-07 07:26:43 +08:00
|
|
|
#include "X86RegisterInfo.h"
|
|
|
|
#include "X86Subtarget.h"
|
2010-05-12 01:31:57 +08:00
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
2014-06-07 07:26:43 +08:00
|
|
|
|
2010-04-17 07:04:22 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:41:26 +08:00
|
|
|
#define DEBUG_TYPE "x86-selectiondag-info"
|
|
|
|
|
2014-08-30 04:50:31 +08:00
|
|
|
bool X86SelectionDAGInfo::isBaseRegConflictPossible(
|
2016-03-02 12:42:31 +08:00
|
|
|
SelectionDAG &DAG, ArrayRef<MCPhysReg> ClobberSet) const {
|
2014-08-30 04:50:31 +08:00
|
|
|
// We cannot use TRI->hasBasePointer() until *after* we select all basic
|
|
|
|
// blocks. Legalization may introduce new stack temporaries with large
|
|
|
|
// alignment requirements. Fall back to generic code if there are any
|
|
|
|
// dynamic stack adjustments (hopefully rare) and the base pointer would
|
|
|
|
// conflict if we had to use it.
|
2016-07-29 02:40:00 +08:00
|
|
|
MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
|
|
|
|
if (!MFI.hasVarSizedObjects() && !MFI.hasOpaqueSPAdjustment())
|
2014-08-30 04:50:31 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
const X86RegisterInfo *TRI = static_cast<const X86RegisterInfo *>(
|
|
|
|
DAG.getSubtarget().getRegisterInfo());
|
Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM
Summary:
This clang-tidy check is looking for unsigned integer variables whose initializer
starts with an implicit cast from llvm::Register and changes the type of the
variable to llvm::Register (dropping the llvm:: where possible).
Partial reverts in:
X86FrameLowering.cpp - Some functions return unsigned and arguably should be MCRegister
X86FixupLEAs.cpp - Some functions return unsigned and arguably should be MCRegister
X86FrameLowering.cpp - Some functions return unsigned and arguably should be MCRegister
HexagonBitSimplify.cpp - Function takes BitTracker::RegisterRef which appears to be unsigned&
MachineVerifier.cpp - Ambiguous operator==() given MCRegister and const Register
PPCFastISel.cpp - No Register::operator-=()
PeepholeOptimizer.cpp - TargetInstrInfo::optimizeLoadInstr() takes an unsigned&
MachineTraceMetrics.cpp - MachineTraceMetrics lacks a suitable constructor
Manual fixups in:
ARMFastISel.cpp - ARMEmitLoad() now takes a Register& instead of unsigned&
HexagonSplitDouble.cpp - Ternary operator was ambiguous between unsigned/Register
HexagonConstExtenders.cpp - Has a local class named Register, used llvm::Register instead of Register.
PPCFastISel.cpp - PPCEmitLoad() now takes a Register& instead of unsigned&
Depends on D65919
Reviewers: arsenm, bogner, craig.topper, RKSimon
Reviewed By: arsenm
Subscribers: RKSimon, craig.topper, lenary, aemerson, wuzish, jholewinski, MatzeB, qcolombet, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, wdng, nhaehnle, sbc100, jgravelle-google, kristof.beyls, hiraditya, aheejin, kbarton, fedor.sergeev, javed.absar, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, tpr, PkmX, jocewei, jsji, Petar.Avramovic, asbirlea, Jim, s.egerton, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65962
llvm-svn: 369041
2019-08-16 03:22:08 +08:00
|
|
|
Register BaseReg = TRI->getBaseRegister();
|
2014-08-30 04:50:31 +08:00
|
|
|
for (unsigned R : ClobberSet)
|
|
|
|
if (BaseReg == R)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-05 01:51:55 +08:00
|
|
|
SDValue X86SelectionDAGInfo::EmitTargetCodeForMemset(
|
2017-04-27 15:22:30 +08:00
|
|
|
SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Val,
|
2015-12-05 01:51:55 +08:00
|
|
|
SDValue Size, unsigned Align, bool isVolatile,
|
|
|
|
MachinePointerInfo DstPtrInfo) const {
|
2010-05-12 01:31:57 +08:00
|
|
|
ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
|
2015-02-03 01:38:43 +08:00
|
|
|
const X86Subtarget &Subtarget =
|
|
|
|
DAG.getMachineFunction().getSubtarget<X86Subtarget>();
|
2010-05-12 01:31:57 +08:00
|
|
|
|
2014-08-30 04:50:31 +08:00
|
|
|
#ifndef NDEBUG
|
|
|
|
// If the base register might conflict with our physical registers, bail out.
|
2016-03-02 12:42:31 +08:00
|
|
|
const MCPhysReg ClobberSet[] = {X86::RCX, X86::RAX, X86::RDI,
|
|
|
|
X86::ECX, X86::EAX, X86::EDI};
|
2014-08-30 04:50:31 +08:00
|
|
|
assert(!isBaseRegConflictPossible(DAG, ClobberSet));
|
|
|
|
#endif
|
|
|
|
|
2010-09-21 13:43:34 +08:00
|
|
|
// If to a segment-relative address space, use the default lowering.
|
|
|
|
if (DstPtrInfo.getAddrSpace() >= 256)
|
|
|
|
return SDValue();
|
2012-08-02 02:39:17 +08:00
|
|
|
|
2010-05-12 01:31:57 +08:00
|
|
|
// If not DWORD aligned or size is more than the threshold, call the library.
|
|
|
|
// The libc version is likely to be faster for these cases. It can use the
|
|
|
|
// address value and run time information about the CPU.
|
2014-06-07 07:26:43 +08:00
|
|
|
if ((Align & 3) != 0 || !ConstantSize ||
|
|
|
|
ConstantSize->getZExtValue() > Subtarget.getMaxInlineSizeThreshold()) {
|
2010-05-12 01:31:57 +08:00
|
|
|
// Check to see if there is a specialized entry-point for memory zeroing.
|
2017-04-27 15:22:30 +08:00
|
|
|
ConstantSDNode *ValC = dyn_cast<ConstantSDNode>(Val);
|
2010-05-12 01:31:57 +08:00
|
|
|
|
2017-12-19 07:14:28 +08:00
|
|
|
if (const char *bzeroName = (ValC && ValC->isNullValue())
|
|
|
|
? DAG.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO)
|
|
|
|
: nullptr) {
|
2015-12-05 01:51:55 +08:00
|
|
|
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
|
|
|
EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout());
|
2015-07-09 10:09:04 +08:00
|
|
|
Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
|
2010-05-12 01:31:57 +08:00
|
|
|
TargetLowering::ArgListTy Args;
|
|
|
|
TargetLowering::ArgListEntry Entry;
|
|
|
|
Entry.Node = Dst;
|
|
|
|
Entry.Ty = IntPtrTy;
|
|
|
|
Args.push_back(Entry);
|
|
|
|
Entry.Node = Size;
|
|
|
|
Args.push_back(Entry);
|
2014-05-18 05:50:17 +08:00
|
|
|
|
|
|
|
TargetLowering::CallLoweringInfo CLI(DAG);
|
2017-03-18 08:43:57 +08:00
|
|
|
CLI.setDebugLoc(dl)
|
|
|
|
.setChain(Chain)
|
2017-03-18 08:44:07 +08:00
|
|
|
.setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
|
2017-12-19 07:14:28 +08:00
|
|
|
DAG.getExternalSymbol(bzeroName, IntPtr),
|
2017-03-18 08:44:07 +08:00
|
|
|
std::move(Args))
|
2017-03-18 08:43:57 +08:00
|
|
|
.setDiscardResult();
|
2014-05-18 05:50:17 +08:00
|
|
|
|
2015-12-05 01:51:55 +08:00
|
|
|
std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
|
2010-05-12 01:31:57 +08:00
|
|
|
return CallResult.second;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise have the target-independent code call memset.
|
|
|
|
return SDValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t SizeVal = ConstantSize->getZExtValue();
|
2014-04-25 13:30:21 +08:00
|
|
|
SDValue InFlag;
|
2010-05-12 01:31:57 +08:00
|
|
|
EVT AVT;
|
|
|
|
SDValue Count;
|
2017-04-27 15:22:30 +08:00
|
|
|
ConstantSDNode *ValC = dyn_cast<ConstantSDNode>(Val);
|
2010-05-12 01:31:57 +08:00
|
|
|
unsigned BytesLeft = 0;
|
|
|
|
if (ValC) {
|
|
|
|
unsigned ValReg;
|
|
|
|
uint64_t Val = ValC->getZExtValue() & 255;
|
|
|
|
|
|
|
|
// If the value is a constant, then we can potentially use larger sets.
|
|
|
|
switch (Align & 3) {
|
|
|
|
case 2: // WORD aligned
|
|
|
|
AVT = MVT::i16;
|
|
|
|
ValReg = X86::AX;
|
|
|
|
Val = (Val << 8) | Val;
|
|
|
|
break;
|
|
|
|
case 0: // DWORD aligned
|
|
|
|
AVT = MVT::i32;
|
|
|
|
ValReg = X86::EAX;
|
|
|
|
Val = (Val << 8) | Val;
|
|
|
|
Val = (Val << 16) | Val;
|
2014-06-07 07:26:43 +08:00
|
|
|
if (Subtarget.is64Bit() && ((Align & 0x7) == 0)) { // QWORD aligned
|
2010-05-12 01:31:57 +08:00
|
|
|
AVT = MVT::i64;
|
|
|
|
ValReg = X86::RAX;
|
|
|
|
Val = (Val << 32) | Val;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: // Byte aligned
|
|
|
|
AVT = MVT::i8;
|
|
|
|
ValReg = X86::AL;
|
2015-04-28 22:05:47 +08:00
|
|
|
Count = DAG.getIntPtrConstant(SizeVal, dl);
|
2010-05-12 01:31:57 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (AVT.bitsGT(MVT::i8)) {
|
|
|
|
unsigned UBytes = AVT.getSizeInBits() / 8;
|
2015-04-28 22:05:47 +08:00
|
|
|
Count = DAG.getIntPtrConstant(SizeVal / UBytes, dl);
|
2010-05-12 01:31:57 +08:00
|
|
|
BytesLeft = SizeVal % UBytes;
|
|
|
|
}
|
|
|
|
|
2015-12-05 01:51:55 +08:00
|
|
|
Chain = DAG.getCopyToReg(Chain, dl, ValReg, DAG.getConstant(Val, dl, AVT),
|
|
|
|
InFlag);
|
2010-05-12 01:31:57 +08:00
|
|
|
InFlag = Chain.getValue(1);
|
|
|
|
} else {
|
|
|
|
AVT = MVT::i8;
|
2015-04-28 22:05:47 +08:00
|
|
|
Count = DAG.getIntPtrConstant(SizeVal, dl);
|
2017-04-27 15:22:30 +08:00
|
|
|
Chain = DAG.getCopyToReg(Chain, dl, X86::AL, Val, InFlag);
|
2010-05-12 01:31:57 +08:00
|
|
|
InFlag = Chain.getValue(1);
|
|
|
|
}
|
|
|
|
|
2018-09-22 13:16:35 +08:00
|
|
|
bool Use64BitRegs = Subtarget.isTarget64BitLP64();
|
|
|
|
Chain = DAG.getCopyToReg(Chain, dl, Use64BitRegs ? X86::RCX : X86::ECX,
|
2014-06-07 07:26:43 +08:00
|
|
|
Count, InFlag);
|
2010-05-12 01:31:57 +08:00
|
|
|
InFlag = Chain.getValue(1);
|
2018-09-22 13:16:35 +08:00
|
|
|
Chain = DAG.getCopyToReg(Chain, dl, Use64BitRegs ? X86::RDI : X86::EDI,
|
2014-06-07 07:26:43 +08:00
|
|
|
Dst, InFlag);
|
2010-05-12 01:31:57 +08:00
|
|
|
InFlag = Chain.getValue(1);
|
|
|
|
|
2010-12-21 10:38:05 +08:00
|
|
|
SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Glue);
|
2010-05-12 01:31:57 +08:00
|
|
|
SDValue Ops[] = { Chain, DAG.getValueType(AVT), InFlag };
|
2014-04-27 02:35:24 +08:00
|
|
|
Chain = DAG.getNode(X86ISD::REP_STOS, dl, Tys, Ops);
|
2010-05-12 01:31:57 +08:00
|
|
|
|
2017-04-21 15:40:59 +08:00
|
|
|
if (BytesLeft) {
|
2010-05-12 01:31:57 +08:00
|
|
|
// Handle the last 1 - 7 bytes.
|
|
|
|
unsigned Offset = SizeVal - BytesLeft;
|
|
|
|
EVT AddrVT = Dst.getValueType();
|
|
|
|
EVT SizeVT = Size.getValueType();
|
|
|
|
|
|
|
|
Chain = DAG.getMemset(Chain, dl,
|
|
|
|
DAG.getNode(ISD::ADD, dl, AddrVT, Dst,
|
2015-04-28 22:05:47 +08:00
|
|
|
DAG.getConstant(Offset, dl, AddrVT)),
|
2017-04-27 15:22:30 +08:00
|
|
|
Val,
|
2015-04-28 22:05:47 +08:00
|
|
|
DAG.getConstant(BytesLeft, dl, SizeVT),
|
2015-04-14 01:16:45 +08:00
|
|
|
Align, isVolatile, false,
|
|
|
|
DstPtrInfo.getWithOffset(Offset));
|
2010-05-12 01:31:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Use a Tokenfactor, as in memcpy, instead of a single chain.
|
|
|
|
return Chain;
|
|
|
|
}
|
|
|
|
|
2019-05-06 23:10:19 +08:00
|
|
|
/// Emit a single REP MOVS{B,W,D,Q} instruction.
|
|
|
|
static SDValue emitRepmovs(const X86Subtarget &Subtarget, SelectionDAG &DAG,
|
|
|
|
const SDLoc &dl, SDValue Chain, SDValue Dst,
|
|
|
|
SDValue Src, SDValue Size, MVT AVT) {
|
|
|
|
const bool Use64BitRegs = Subtarget.isTarget64BitLP64();
|
|
|
|
const unsigned CX = Use64BitRegs ? X86::RCX : X86::ECX;
|
|
|
|
const unsigned DI = Use64BitRegs ? X86::RDI : X86::EDI;
|
|
|
|
const unsigned SI = Use64BitRegs ? X86::RSI : X86::ESI;
|
|
|
|
|
|
|
|
SDValue InFlag;
|
|
|
|
Chain = DAG.getCopyToReg(Chain, dl, CX, Size, InFlag);
|
|
|
|
InFlag = Chain.getValue(1);
|
|
|
|
Chain = DAG.getCopyToReg(Chain, dl, DI, Dst, InFlag);
|
|
|
|
InFlag = Chain.getValue(1);
|
|
|
|
Chain = DAG.getCopyToReg(Chain, dl, SI, Src, InFlag);
|
|
|
|
InFlag = Chain.getValue(1);
|
|
|
|
|
|
|
|
SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Glue);
|
|
|
|
SDValue Ops[] = {Chain, DAG.getValueType(AVT), InFlag};
|
|
|
|
return DAG.getNode(X86ISD::REP_MOVS, dl, Tys, Ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Emit a single REP MOVSB instruction for a particular constant size.
|
|
|
|
static SDValue emitRepmovsB(const X86Subtarget &Subtarget, SelectionDAG &DAG,
|
|
|
|
const SDLoc &dl, SDValue Chain, SDValue Dst,
|
|
|
|
SDValue Src, uint64_t Size) {
|
|
|
|
return emitRepmovs(Subtarget, DAG, dl, Chain, Dst, Src,
|
|
|
|
DAG.getIntPtrConstant(Size, dl), MVT::i8);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns the best type to use with repmovs depending on alignment.
|
|
|
|
static MVT getOptimalRepmovsType(const X86Subtarget &Subtarget,
|
|
|
|
uint64_t Align) {
|
|
|
|
assert((Align != 0) && "Align is normalized");
|
|
|
|
assert(isPowerOf2_64(Align) && "Align is a power of 2");
|
|
|
|
switch (Align) {
|
|
|
|
case 1:
|
|
|
|
return MVT::i8;
|
|
|
|
case 2:
|
|
|
|
return MVT::i16;
|
|
|
|
case 4:
|
|
|
|
return MVT::i32;
|
|
|
|
default:
|
|
|
|
return Subtarget.is64Bit() ? MVT::i64 : MVT::i32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns a REP MOVS instruction, possibly with a few load/stores to implement
|
|
|
|
/// a constant size memory copy. In some cases where we know REP MOVS is
|
|
|
|
/// inefficient we return an empty SDValue so the calling code can either
|
|
|
|
/// generate a load/store sequence or call the runtime memcpy function.
|
|
|
|
static SDValue emitConstantSizeRepmov(
|
|
|
|
SelectionDAG &DAG, const X86Subtarget &Subtarget, const SDLoc &dl,
|
|
|
|
SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, EVT SizeVT,
|
|
|
|
unsigned Align, bool isVolatile, bool AlwaysInline,
|
|
|
|
MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) {
|
|
|
|
|
|
|
|
/// TODO: Revisit next line: big copy with ERMSB on march >= haswell are very
|
|
|
|
/// efficient.
|
|
|
|
if (!AlwaysInline && Size > Subtarget.getMaxInlineSizeThreshold())
|
2010-05-12 01:31:57 +08:00
|
|
|
return SDValue();
|
|
|
|
|
2019-05-06 23:10:19 +08:00
|
|
|
/// If we have enhanced repmovs we use it.
|
|
|
|
if (Subtarget.hasERMSB())
|
|
|
|
return emitRepmovsB(Subtarget, DAG, dl, Chain, Dst, Src, Size);
|
|
|
|
|
|
|
|
assert(!Subtarget.hasERMSB() && "No efficient RepMovs");
|
|
|
|
/// We assume runtime memcpy will do a better job for unaligned copies when
|
|
|
|
/// ERMS is not present.
|
2010-11-05 05:16:46 +08:00
|
|
|
if (!AlwaysInline && (Align & 3) != 0)
|
2010-05-12 01:31:57 +08:00
|
|
|
return SDValue();
|
|
|
|
|
2019-05-06 23:10:19 +08:00
|
|
|
const MVT BlockType = getOptimalRepmovsType(Subtarget, Align);
|
|
|
|
const uint64_t BlockBytes = BlockType.getSizeInBits() / 8;
|
|
|
|
const uint64_t BlockCount = Size / BlockBytes;
|
|
|
|
const uint64_t BytesLeft = Size % BlockBytes;
|
|
|
|
SDValue RepMovs =
|
|
|
|
emitRepmovs(Subtarget, DAG, dl, Chain, Dst, Src,
|
|
|
|
DAG.getIntPtrConstant(BlockCount, dl), BlockType);
|
|
|
|
|
|
|
|
/// RepMov can process the whole length.
|
|
|
|
if (BytesLeft == 0)
|
|
|
|
return RepMovs;
|
|
|
|
|
|
|
|
assert(BytesLeft && "We have leftover at this point");
|
|
|
|
|
|
|
|
/// In case we optimize for size we use repmovsb even if it's less efficient
|
|
|
|
/// so we can save the loads/stores of the leftover.
|
|
|
|
if (DAG.getMachineFunction().getFunction().hasMinSize())
|
|
|
|
return emitRepmovsB(Subtarget, DAG, dl, Chain, Dst, Src, Size);
|
|
|
|
|
|
|
|
// Handle the last 1 - 7 bytes.
|
|
|
|
SmallVector<SDValue, 4> Results;
|
|
|
|
Results.push_back(RepMovs);
|
|
|
|
unsigned Offset = Size - BytesLeft;
|
|
|
|
EVT DstVT = Dst.getValueType();
|
|
|
|
EVT SrcVT = Src.getValueType();
|
|
|
|
Results.push_back(DAG.getMemcpy(
|
|
|
|
Chain, dl,
|
|
|
|
DAG.getNode(ISD::ADD, dl, DstVT, Dst, DAG.getConstant(Offset, dl, DstVT)),
|
|
|
|
DAG.getNode(ISD::ADD, dl, SrcVT, Src, DAG.getConstant(Offset, dl, SrcVT)),
|
|
|
|
DAG.getConstant(BytesLeft, dl, SizeVT), Align, isVolatile,
|
|
|
|
/*AlwaysInline*/ true, /*isTailCall*/ false,
|
|
|
|
DstPtrInfo.getWithOffset(Offset), SrcPtrInfo.getWithOffset(Offset)));
|
|
|
|
return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Results);
|
|
|
|
}
|
|
|
|
|
|
|
|
SDValue X86SelectionDAGInfo::EmitTargetCodeForMemcpy(
|
|
|
|
SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
|
|
|
|
SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline,
|
|
|
|
MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
|
2010-09-21 13:43:34 +08:00
|
|
|
// If to a segment-relative address space, use the default lowering.
|
2019-05-06 23:10:19 +08:00
|
|
|
if (DstPtrInfo.getAddrSpace() >= 256 || SrcPtrInfo.getAddrSpace() >= 256)
|
2010-09-21 13:43:34 +08:00
|
|
|
return SDValue();
|
2010-11-05 05:16:46 +08:00
|
|
|
|
2019-05-06 23:10:19 +08:00
|
|
|
// If the base registers conflict with our physical registers, use the default
|
|
|
|
// lowering.
|
2016-03-02 12:42:31 +08:00
|
|
|
const MCPhysReg ClobberSet[] = {X86::RCX, X86::RSI, X86::RDI,
|
|
|
|
X86::ECX, X86::ESI, X86::EDI};
|
2014-08-30 04:50:31 +08:00
|
|
|
if (isBaseRegConflictPossible(DAG, ClobberSet))
|
Revert "X86 memcpy lowering: use "rep movs" even when esi is used as base pointer" (r204174)
> For functions where esi is used as base pointer, we would previously fall ba
> from lowering memcpy with "rep movs" because that clobbers esi.
>
> With this patch, we just store esi in another physical register, and restore
> it afterwards. This adds a little bit of register preassure, but the more
> efficient memcpy should be worth it.
>
> Differential Revision: http://llvm-reviews.chandlerc.com/D2968
This didn't work. I was ending up with code like this:
lea edi,[esi+38h]
mov ecx,0Fh
mov edx,esi
mov esi,ebx
rep movs dword ptr es:[edi],dword ptr [esi]
lea ecx,[esi+74h] <-- Ooops, we're now using esi before restoring it from edx.
add ebx,3Ch
mov esi,edx
I guess if we want to do this we need stronger glue or something, or doing the expansion
much later.
llvm-svn: 204829
2014-03-27 00:30:54 +08:00
|
|
|
return SDValue();
|
2013-02-13 21:40:35 +08:00
|
|
|
|
2019-05-06 23:10:19 +08:00
|
|
|
const X86Subtarget &Subtarget =
|
|
|
|
DAG.getMachineFunction().getSubtarget<X86Subtarget>();
|
2010-05-12 01:31:57 +08:00
|
|
|
|
2019-05-06 23:10:19 +08:00
|
|
|
/// Handle constant sizes,
|
|
|
|
if (ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size))
|
|
|
|
return emitConstantSizeRepmov(DAG, Subtarget, dl, Chain, Dst, Src,
|
|
|
|
ConstantSize->getZExtValue(),
|
|
|
|
Size.getValueType(), Align, isVolatile,
|
|
|
|
AlwaysInline, DstPtrInfo, SrcPtrInfo);
|
2010-05-12 01:31:57 +08:00
|
|
|
|
2019-05-06 23:10:19 +08:00
|
|
|
return SDValue();
|
2010-05-12 01:31:57 +08:00
|
|
|
}
|