[all-commits] [llvm/llvm-project] 516915: [InstCombine] Fold memchr and strchr equality with...

Martin Sebor via All-commits all-commits at lists.llvm.org
Thu Jul 7 14:16:30 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 516915beb5ee5012a9a8b162fc29664a8c247ec3
      https://github.com/llvm/llvm-project/commit/516915beb5ee5012a9a8b162fc29664a8c247ec3
  Author: Martin Sebor <msebor at redhat.com>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
    M llvm/test/Transforms/InstCombine/memchr-11.ll
    M llvm/test/Transforms/InstCombine/strchr-4.ll

  Log Message:
  -----------
  [InstCombine] Fold memchr and strchr equality with first argument

Enhance memchr and strchr handling to simplify calls to the functions
used in equality expressions with the first argument to at most two
integer comparisons:

- memchr(A, C, N) == A to N && *A == C for either a dereferenceable
  A or a nonzero N,
- strchr(S, C) == S to *S == C for any S and C, and
- strchr(S, '\0') == 0 to true for any S

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D128939




More information about the All-commits mailing list