[PATCH] D128011: [SimplifyLibCalls] Transform memchr(STR C, N) to chain of ORs

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 14:51:54 PDT 2022


xbolva00 created this revision.
xbolva00 added reviewers: msebor, nikic.
Herald added a subscriber: hiraditya.
Herald added a project: All.
xbolva00 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Motivation:

  #include <string_view>
  
  size_t findFirst_ABCDEF(std::string_view sv) {
    return sv.find_first_of("ABCDEF");
  }

memchr("ABCDEF", C,  6) != NULL -> (C == 'A' || C == 'B' || C == 'C' || C == 'D' || C == 'E' || C == 'F') != 0


https://reviews.llvm.org/D128011

Files:
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/test/Transforms/InstCombine/memchr-7.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128011.437715.patch
Type: text/x-patch
Size: 4845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220616/98b2d05b/attachment.bin>


More information about the llvm-commits mailing list