Please sign in to comment.
[SelectionDAG] Allow the user to specify a memeq function.
Summary: Right now, when we encounter a string equality check, e.g. `if (memcmp(a, b, s) == 0)`, we try to expand to a comparison if `s` is a small compile-time constant, and fall back on calling `memcmp()` else. This is sub-optimal because memcmp has to compute much more than equality. This patch replaces `memcmp(a, b, s) == 0` by `bcmp(a, b, s) == 0` on platforms that support `bcmp`. `bcmp` can be made much more efficient than `memcmp` because equality compare is trivially parallel while lexicographic ordering has a chain dependency. Subscribers: fedor.sergeev, jyknight, ckennelly, gchatelet, llvm-commits Differential Revision: https://reviews.llvm.org/D56593 llvm-svn: 355672
- Loading branch information...
Showing with 187 additions and 28 deletions.
- +5 −0 llvm/docs/ReleaseNotes.rst
- +4 −0 llvm/include/llvm/Transforms/Utils/BuildLibCalls.h
- +13 −0 llvm/lib/Analysis/TargetLibraryInfo.cpp
- +22 −9 llvm/lib/Transforms/Utils/BuildLibCalls.cpp
- +27 −14 llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
- +67 −0 llvm/test/CodeGen/X86/memcmp.ll
- +6 −3 llvm/test/Transforms/InferFunctionAttrs/annotate.ll
- +20 −1 llvm/test/Transforms/InstCombine/memcmp-1.ll
- +23 −1 llvm/test/Transforms/InstCombine/strcmp-1.ll