[PATCH] D68089: [InstCombine] Optimize some memccpy calls to memcpy/null

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 20:13:19 PDT 2019


jdoerfert added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1138
+    return nullptr;
+  size_t Pos = SrcStr.find(StopChar->getSExtValue());
+  if (Pos == StringRef::npos) {
----------------
xbolva00 wrote:
> jdoerfert wrote:
> > I do not know so I ask, is SExt the right choice here or ZExt? StopChar could be `i8 -1` right? Now the question is, what do we want to find in SrcStr, `-1` or `255`?
> Inspired by optimizeStrChr, that code uses  Str.find(CharC->getSExtValue()); so I think it is OK.
I dislike this reason, maybe that case was missed there as well. Could we make a test (and execute it) with a string that has `i8 -1` as character and we look for that one with memccpy just to be sure?


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

https://reviews.llvm.org/D68089





More information about the llvm-commits mailing list