Skip to content

Commit c1326f8

Browse files
preamesGeorgeARM
authored andcommitted
[SDAG] Merge memcpy and memcpy.inline lowering paths (llvm#138619)
This is a follow up to c0a264e, but note that there is a functional difference here: the root changes for the memcpy.inline case. This difference appears to have been accidental, but I kept this back to facility separate review in case there's something I'm missing here.
1 parent b0f53b0 commit c1326f8

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6461,42 +6461,24 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
64616461
RegName, getValue(RegValue)));
64626462
return;
64636463
}
6464-
case Intrinsic::memcpy: {
6465-
const auto &MCI = cast<MemCpyInst>(I);
6466-
SDValue Op1 = getValue(I.getArgOperand(0));
6467-
SDValue Op2 = getValue(I.getArgOperand(1));
6468-
SDValue Op3 = getValue(I.getArgOperand(2));
6469-
// @llvm.memcpy defines 0 and 1 to both mean no alignment.
6470-
Align DstAlign = MCI.getDestAlign().valueOrOne();
6471-
Align SrcAlign = MCI.getSourceAlign().valueOrOne();
6472-
Align Alignment = std::min(DstAlign, SrcAlign);
6473-
bool isVol = MCI.isVolatile();
6474-
// FIXME: Support passing different dest/src alignments to the memcpy DAG
6475-
// node.
6476-
SDValue Root = isVol ? getRoot() : getMemoryRoot();
6477-
SDValue MC = DAG.getMemcpy(Root, sdl, Op1, Op2, Op3, Alignment, isVol,
6478-
/* AlwaysInline */ false, &I, std::nullopt,
6479-
MachinePointerInfo(I.getArgOperand(0)),
6480-
MachinePointerInfo(I.getArgOperand(1)),
6481-
I.getAAMetadata(), BatchAA);
6482-
updateDAGForMaybeTailCall(MC);
6483-
return;
6484-
}
6464+
case Intrinsic::memcpy:
64856465
case Intrinsic::memcpy_inline: {
64866466
const auto &MCI = cast<MemCpyInst>(I);
64876467
SDValue Dst = getValue(I.getArgOperand(0));
64886468
SDValue Src = getValue(I.getArgOperand(1));
64896469
SDValue Size = getValue(I.getArgOperand(2));
6490-
assert(isa<ConstantSDNode>(Size) && "memcpy_inline needs constant size");
6470+
assert((!MCI.isForceInlined() || isa<ConstantSDNode>(Size)) &&
6471+
"memcpy_inline needs constant size");
64916472
// @llvm.memcpy.inline defines 0 and 1 to both mean no alignment.
64926473
Align DstAlign = MCI.getDestAlign().valueOrOne();
64936474
Align SrcAlign = MCI.getSourceAlign().valueOrOne();
64946475
Align Alignment = std::min(DstAlign, SrcAlign);
64956476
bool isVol = MCI.isVolatile();
64966477
// FIXME: Support passing different dest/src alignments to the memcpy DAG
64976478
// node.
6498-
SDValue MC = DAG.getMemcpy(getRoot(), sdl, Dst, Src, Size, Alignment, isVol,
6499-
/* AlwaysInline */ true, &I, std::nullopt,
6479+
SDValue Root = isVol ? getRoot() : getMemoryRoot();
6480+
SDValue MC = DAG.getMemcpy(Root, sdl, Dst, Src, Size, Alignment, isVol,
6481+
MCI.isForceInlined(), &I, std::nullopt,
65006482
MachinePointerInfo(I.getArgOperand(0)),
65016483
MachinePointerInfo(I.getArgOperand(1)),
65026484
I.getAAMetadata(), BatchAA);

0 commit comments

Comments
 (0)