diff options
author | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-08-12 10:28:10 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-08-12 10:28:10 +0000 |
commit | ac168b8bc8773a083a10902f64e4ae57a925aee4 (patch) | |
tree | f01bc6788d39669344e52a5304fbe7859ebc8702 /lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp | |
parent | e03a56d62fc623e2f72d623b816f91b293d5904b (diff) | |
download | external_llvm-ac168b8bc8773a083a10902f64e4ae57a925aee4.zip external_llvm-ac168b8bc8773a083a10902f64e4ae57a925aee4.tar.gz external_llvm-ac168b8bc8773a083a10902f64e4ae57a925aee4.tar.bz2 |
[SystemZ] Use CLC and IPM to implement memcmp
For now this is restricted to fixed-length comparisons with a length
in the range [1, 256], as for memcpy() and MVC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp')
-rw-r--r-- | lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp b/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp index 4ca9292..341dc94 100644 --- a/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp +++ b/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp @@ -125,3 +125,30 @@ EmitTargetCodeForMemset(SelectionDAG &DAG, SDLoc DL, SDValue Chain, } return SDValue(); } + +std::pair<SDValue, SDValue> SystemZSelectionDAGInfo:: +EmitTargetCodeForMemcmp(SelectionDAG &DAG, SDLoc DL, SDValue Chain, + SDValue Src1, SDValue Src2, SDValue Size, + MachinePointerInfo Op1PtrInfo, + MachinePointerInfo Op2PtrInfo) const { + if (ConstantSDNode *CSize = dyn_cast<ConstantSDNode>(Size)) { + uint64_t Bytes = CSize->getZExtValue(); + if (Bytes >= 1 && Bytes <= 0x100) { + // A single CLC. + SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Glue); + Chain = DAG.getNode(SystemZISD::CLC, DL, VTs, Chain, + Src1, Src2, Size); + SDValue Glue = Chain.getValue(1); + // IPM inserts the CC value into bits 29 and 28, with 0 meaning "equal", + // 1 meaning "greater" and 2 meaning "less". Convert them into an + // integer that is respectively equal, greater or less than 0. + SDValue IPM = DAG.getNode(SystemZISD::IPM, DL, MVT::i32, Glue); + SDValue SHL = DAG.getNode(ISD::SHL, DL, MVT::i32, IPM, + DAG.getConstant(2, MVT::i32)); + SDValue SRA = DAG.getNode(ISD::SRA, DL, MVT::i32, SHL, + DAG.getConstant(30, MVT::i32)); + return std::make_pair(SRA, Chain); + } + } + return std::make_pair(SDValue(), SDValue()); +} |