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

Martin Sebor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 17 08:05:38 PDT 2022


msebor added a comment.

An analogous optimization is applicable to other string functions besides `memchr` (and `strchr`), including for example `strlen` or even `memcmp` and `strcmp` (with one short constant array/string).  With this one accepted as a precedent the other handlers can be enhanced as follow ups.  It would be nice if the algorithm could be made general enough to let them all share it.  It does seem that the expansion in all of them should be capped at some small number.

For what it's worth, a prototype of the corresponding patch for GCC is attached to PR  103798 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103798>.  It looks like it has a hardwired limit of 8 bytes.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128011/new/

https://reviews.llvm.org/D128011



More information about the llvm-commits mailing list