[PATCH] D128954: [InstCombine] Transform strrchr to memrchr for constant strings
Martin Sebor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 30 15:13:11 PDT 2022
msebor created this revision.
msebor added reviewers: xbolva00, nikic.
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 adds a `memrchr` library function call emitter and simplifies the `strrchr` call handler to use it instead of duplicating a subset of the former function's transformations in the handler. This in turn enables transforming calls with the empty string `S` such as `strrchr(S, C)` to the test `C ? S : 0`. A call to `memrchr` when the length of the string is known is also likely to be faster than one to `strrchr` with the corresponding arguments.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128954
Files:
llvm/include/llvm/Transforms/Utils/BuildLibCalls.h
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/strcall-no-nul.ll
llvm/test/Transforms/InstCombine/strrchr-1.ll
llvm/test/Transforms/InstCombine/strrchr-3.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128954.441528.patch
Type: text/x-patch
Size: 7752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/09f2ce1f/attachment.bin>
More information about the llvm-commits
mailing list