diff options
| author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2021-10-12 12:35:01 +0200 |
|---|---|---|
| committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2021-10-14 10:37:33 +0200 |
| commit | a33e4c8ae925e99e565b2ca5dcda8ec2edbb78ee (patch) | |
| tree | a83fba1932be692adc1e65ffb8e13a48e6503921 /llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp | |
| parent | 00baad35b2a366437e210a0701173247a3ad5468 (diff) | |
[SystemZ] Reapply memcmp and memcpy patches.
This reverts 3562076 and includes some refactoring as well.
Review: Ulrich Weigand
Differential Revision: https://reviews.llvm.org/D111733
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp b/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp index edf4a7ce20d4..f38e93109967 100644 --- a/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp @@ -17,6 +17,11 @@ using namespace llvm; #define DEBUG_TYPE "systemz-selectiondag-info" +static SDVTList getMemMemVTs(unsigned Op, SelectionDAG &DAG) { + return Op == SystemZISD::CLC ? DAG.getVTList(MVT::i32, MVT::Other) + : DAG.getVTList(MVT::Other); +} + // Emit a mem-mem operation after subtracting one from size, which will be // added back during pseudo expansion. As the Reg case emitted here may be // converted by DAGCombiner into having an Imm length, they are both emitted @@ -24,7 +29,7 @@ using namespace llvm; static SDValue emitMemMemImm(SelectionDAG &DAG, const SDLoc &DL, unsigned Op, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size) { - return DAG.getNode(Op, DL, MVT::Other, Chain, Dst, Src, + return DAG.getNode(Op, DL, getMemMemVTs(Op, DAG), Chain, Dst, Src, DAG.getConstant(Size - 1, DL, Src.getValueType())); } @@ -34,17 +39,7 @@ static SDValue emitMemMemReg(SelectionDAG &DAG, const SDLoc &DL, unsigned Op, SDValue LenMinus1 = DAG.getNode(ISD::ADD, DL, MVT::i64, DAG.getZExtOrTrunc(Size, DL, MVT::i64), DAG.getConstant(-1, DL, MVT::i64)); - return DAG.getNode(Op, DL, MVT::Other, Chain, Dst, Src, LenMinus1); -} - -// Use CLC to compare [Src1, Src1 + Size) with [Src2, Src2 + Size). -// One is subtracted from size also here, per above. -static SDValue emitCLC(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, - SDValue Src1, SDValue Src2, uint64_t Size) { - SDVTList VTs = DAG.getVTList(MVT::i32, MVT::Other); - EVT PtrVT = Src1.getValueType(); - return DAG.getNode(SystemZISD::CLC, DL, VTs, Chain, Src1, Src2, - DAG.getConstant(Size - 1, DL, PtrVT)); + return DAG.getNode(Op, DL, getMemMemVTs(Op, DAG), Chain, Dst, Src, LenMinus1); } SDValue SystemZSelectionDAGInfo::EmitTargetCodeForMemcpy( @@ -57,7 +52,8 @@ SDValue SystemZSelectionDAGInfo::EmitTargetCodeForMemcpy( if (auto *CSize = dyn_cast<ConstantSDNode>(Size)) return emitMemMemImm(DAG, DL, SystemZISD::MVC, Chain, Dst, Src, CSize->getZExtValue()); - return SDValue(); + + return emitMemMemReg(DAG, DL, SystemZISD::MVC, Chain, Dst, Src, Size); } // Handle a memset of 1, 2, 4 or 8 bytes with the operands given by @@ -166,15 +162,16 @@ std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForMemcmp( SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src1, SDValue Src2, SDValue Size, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const { + SDValue CCReg; + // Swap operands to invert CC == 1 vs. CC == 2 cases. if (auto *CSize = dyn_cast<ConstantSDNode>(Size)) { uint64_t Bytes = CSize->getZExtValue(); assert(Bytes > 0 && "Caller should have handled 0-size case"); - // Swap operands to invert CC == 1 vs. CC == 2 cases. - SDValue CCReg = emitCLC(DAG, DL, Chain, Src2, Src1, Bytes); - Chain = CCReg.getValue(1); - return std::make_pair(addIPMSequence(DL, CCReg, DAG), Chain); - } - return std::make_pair(SDValue(), SDValue()); + CCReg = emitMemMemImm(DAG, DL, SystemZISD::CLC, Chain, Src2, Src1, Bytes); + } else + CCReg = emitMemMemReg(DAG, DL, SystemZISD::CLC, Chain, Src2, Src1, Size); + Chain = CCReg.getValue(1); + return std::make_pair(addIPMSequence(DL, CCReg, DAG), Chain); } std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForMemchr( |
