diff options
author | David Bolvansky <david.bolvansky@gmail.com> | 2019-10-02 22:49:20 +0000 |
---|---|---|
committer | David Bolvansky <david.bolvansky@gmail.com> | 2019-10-02 22:49:20 +0000 |
commit | 6b45029676e5d0b5eb5baddab919c511881dd186 (patch) | |
tree | 803683d1f0de3c345d26a5de37149fa069266c5e /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | |
parent | f5bda7fe24edd21a7f3fc71129d1cca8fd277a1d (diff) | |
download | llvm-6b45029676e5d0b5eb5baddab919c511881dd186.zip llvm-6b45029676e5d0b5eb5baddab919c511881dd186.tar.gz llvm-6b45029676e5d0b5eb5baddab919c511881dd186.tar.bz2 |
[InstCombine] Transform bcopy to memmove
bcopy is still widely used mainly for network apps. Sadly, LLVM has no optimizations for bcopy, but there are some for memmove.
Since bcopy == memmove, it is profitable to transform bcopy to memmove and use current optimizations for memmove for free here.
llvm-svn: 373537
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 3af754a..1fb4f28 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -2792,6 +2792,12 @@ Value *LibCallSimplifier::optimizePuts(CallInst *CI, IRBuilder<> &B) { return nullptr; } +Value *LibCallSimplifier::optimizeBCopy(CallInst *CI, IRBuilder<> &B) { + // bcopy(src, dst, n) -> llvm.memmove(dst, src, n) + return B.CreateMemMove(CI->getArgOperand(1), 1, CI->getArgOperand(0), 1, + CI->getArgOperand(2)); +} + bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) { LibFunc Func; SmallString<20> FloatFuncName = FuncName; @@ -2870,6 +2876,8 @@ Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI, return optimizeRealloc(CI, Builder); case LibFunc_wcslen: return optimizeWcslen(CI, Builder); + case LibFunc_bcopy: + return optimizeBCopy(CI, Builder); default: break; } |