[PATCH] D128939: [InstCombine] Fold memchr and strchr equality with first argument
Martin Sebor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 30 12:51:06 PDT 2022
msebor created this revision.
msebor added reviewers: xbolva00, nikic, bkramer.
Herald added a subscriber: hiraditya.
Herald added a project: All.
msebor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This change enhances `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`
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128939
Files:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/memchr-11.ll
llvm/test/Transforms/InstCombine/memrchr-8.ll
llvm/test/Transforms/InstCombine/strchr-4.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128939.441491.patch
Type: text/x-patch
Size: 14604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/287b8e68/attachment.bin>
More information about the llvm-commits
mailing list