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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 14:33:55 PDT 2019


efriedma added a comment.

(Comments using argument names from the signature `void *memccpy(void *dest, const void *src, int c, size_t n);`.)

Please add a testcase where the optimization triggers and "c" is 0.  (I think getConstantStringInfo trims the null terminator by default?)

It should be possible to optimize cases where "c" doesn't appear in "src" if "n" is smaller than the length of "src".



================
Comment at: test/Transforms/InstCombine/memccpy.ll:57
+; CHECK-LABEL: @memccpy_to_null3(
+; CHECK-NEXT:    ret i8* null
+;
----------------
This is obviously wrong; you've removed the side-effect.


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

https://reviews.llvm.org/D68089





More information about the llvm-commits mailing list