[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
Wed Jun 22 11:39:24 PDT 2022
msebor added a comment.
It seems important to put a limit on the length of the chain to avoid pathological expansion (that might come up in generated code, but not only there). I expect the optimal maximum will vary across different targets but a suitably low minimum should be target-independent. I don't have a good sense of what the ideal lower bound might be but I would hesitate to go over the proposed GCC limit of 8 unless the ORs could be assumed to collapse to something much simpler (like in `memchr-7.ll`). Instrumenting the compiler and building a few projects might help dial it in.
Having said that, I don't think it's a guaranteed win to set the limit to zero (or to disable the subsequent folding) when optimizing for size. But whatever the effect of `-Os` might be here, it should be exercised by the test suite if only to make the decision explicit.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128011/new/
https://reviews.llvm.org/D128011
More information about the llvm-commits
mailing list