[PATCH] D56593: [SelectionDAG][RFC] Allow the user to specify a memeq function (v5).

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 11 04:45:42 PST 2019


courbet created this revision.
Herald added a subscriber: fedor.sergeev.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D56593

Files:
  lib/Analysis/TargetLibraryInfo.cpp
  lib/Transforms/Utils/SimplifyLibCalls.cpp
  test/CodeGen/X86/memcmp.ll
  test/Transforms/InferFunctionAttrs/annotate.ll
  test/Transforms/InstCombine/memcmp-1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56593.181249.patch
Type: text/x-patch
Size: 9061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190111/92916def/attachment.bin>


More information about the llvm-commits mailing list