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/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
parent | e03a56d62fc623e2f72d623b816f91b293d5904b (diff) | |
download | llvm-ac168b8bc8773a083a10902f64e4ae57a925aee4.tar.gz llvm-ac168b8bc8773a083a10902f64e4ae57a925aee4.tar.bz2 llvm-ac168b8bc8773a083a10902f64e4ae57a925aee4.tar.xz |
[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/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index e23c5bea22..1101ee1c50 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -58,6 +58,7 @@ #include "llvm/Target/TargetLibraryInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Target/TargetSelectionDAGInfo.h" #include <algorithm> using namespace llvm; @@ -5463,6 +5464,26 @@ bool SelectionDAGBuilder::visitMemCmpCall(const CallInst &I) { return false; const ConstantInt *Size = dyn_cast<ConstantInt>(I.getArgOperand(2)); + if (Size && Size->getZExtValue() == 0) { + EVT CallVT = TM.getTargetLowering()->getValueType(I.getType(), true); + setValue(&I, DAG.getConstant(0, CallVT)); + return true; + } + + const Value *Arg0 = I.getArgOperand(0); + const Value *Arg1 = I.getArgOperand(1); + const Value *Arg2 = I.getArgOperand(2); + const TargetSelectionDAGInfo &TSI = DAG.getSelectionDAGInfo(); + std::pair<SDValue, SDValue> Res = + TSI.EmitTargetCodeForMemcmp(DAG, getCurSDLoc(), DAG.getRoot(), + getValue(Arg0), getValue(Arg1), getValue(Arg2), + MachinePointerInfo(Arg0), + MachinePointerInfo(Arg1)); + if (Res.first.getNode()) { + setValue(&I, Res.first); + DAG.setRoot(Res.second); + return true; + } // memcmp(S1,S2,2) != 0 -> (*(short*)LHS != *(short*)RHS) != 0 // memcmp(S1,S2,4) != 0 -> (*(int*)LHS != *(int*)RHS) != 0 |