]> granicus.if.org Git - llvm/commit
[SelectionDAG] Allow the user to specify a memeq function.
authorClement Courbet <courbet@google.com>
Fri, 8 Mar 2019 09:07:45 +0000 (09:07 +0000)
committerClement Courbet <courbet@google.com>
Fri, 8 Mar 2019 09:07:45 +0000 (09:07 +0000)
commit154171347ba3d136a50c6898f8ce5f27eb4081c2
tree7d88fe1b15f37486f59296007c0528b43e8c2591
parent5b94cee9307257e3562982ad9a076b077a5dea42
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355672 91177308-0d34-0410-b5e6-96231b3b80d8
docs/ReleaseNotes.rst
include/llvm/Transforms/Utils/BuildLibCalls.h
lib/Analysis/TargetLibraryInfo.cpp
lib/Transforms/Utils/BuildLibCalls.cpp
lib/Transforms/Utils/SimplifyLibCalls.cpp
test/CodeGen/X86/memcmp.ll
test/Transforms/InferFunctionAttrs/annotate.ll
test/Transforms/InstCombine/memcmp-1.ll
test/Transforms/InstCombine/strcmp-1.ll