[llvm] [SDAG] Merge memcpy and memcpy.inline lowering paths (PR #138619)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 5 18:16:18 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Philip Reames (preames)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/138619.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+6-24)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 744a0fa572b0c..97ce20b973204 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -6461,33 +6461,14 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
RegName, getValue(RegValue)));
return;
}
- case Intrinsic::memcpy: {
- const auto &MCI = cast<MemCpyInst>(I);
- SDValue Op1 = getValue(I.getArgOperand(0));
- SDValue Op2 = getValue(I.getArgOperand(1));
- SDValue Op3 = getValue(I.getArgOperand(2));
- // @llvm.memcpy defines 0 and 1 to both mean no alignment.
- Align DstAlign = MCI.getDestAlign().valueOrOne();
- Align SrcAlign = MCI.getSourceAlign().valueOrOne();
- Align Alignment = std::min(DstAlign, SrcAlign);
- bool isVol = MCI.isVolatile();
- // FIXME: Support passing different dest/src alignments to the memcpy DAG
- // node.
- SDValue Root = isVol ? getRoot() : getMemoryRoot();
- SDValue MC = DAG.getMemcpy(Root, sdl, Op1, Op2, Op3, Alignment, isVol,
- /* AlwaysInline */ false, &I, std::nullopt,
- MachinePointerInfo(I.getArgOperand(0)),
- MachinePointerInfo(I.getArgOperand(1)),
- I.getAAMetadata(), BatchAA);
- updateDAGForMaybeTailCall(MC);
- return;
- }
+ case Intrinsic::memcpy:
case Intrinsic::memcpy_inline: {
const auto &MCI = cast<MemCpyInst>(I);
SDValue Dst = getValue(I.getArgOperand(0));
SDValue Src = getValue(I.getArgOperand(1));
SDValue Size = getValue(I.getArgOperand(2));
- assert(isa<ConstantSDNode>(Size) && "memcpy_inline needs constant size");
+ assert((!MCI.isForceInlined() || isa<ConstantSDNode>(Size)) &&
+ "memcpy_inline needs constant size");
// @llvm.memcpy.inline defines 0 and 1 to both mean no alignment.
Align DstAlign = MCI.getDestAlign().valueOrOne();
Align SrcAlign = MCI.getSourceAlign().valueOrOne();
@@ -6495,8 +6476,9 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
bool isVol = MCI.isVolatile();
// FIXME: Support passing different dest/src alignments to the memcpy DAG
// node.
- SDValue MC = DAG.getMemcpy(getRoot(), sdl, Dst, Src, Size, Alignment, isVol,
- /* AlwaysInline */ true, &I, std::nullopt,
+ SDValue Root = isVol ? getRoot() : getMemoryRoot();
+ SDValue MC = DAG.getMemcpy(Root, sdl, Dst, Src, Size, Alignment, isVol,
+ MCI.isForceInlined(), &I, std::nullopt,
MachinePointerInfo(I.getArgOperand(0)),
MachinePointerInfo(I.getArgOperand(1)),
I.getAAMetadata(), BatchAA);
``````````
</details>
https://github.com/llvm/llvm-project/pull/138619
More information about the llvm-commits
mailing list