https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96754

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=88814
   Last reconfirmed|                            |2020-08-24
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
             Blocks|                            |83819
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
f1() is equivalent to:

  char *c = memccpy (a, b, 0, SIZE_MAX);
  return c - a - 1;

When memccpy is available (or when it's provided by GCC as a built-in as
suggested in pr88814) it could be used to implement the suggested optimization
as well.  The result of such transformations is only going to be optimally
efficient if libc implements memccpy as a single-pass algorithm rather than as
memcpy(a, b, memchr (b, c) - b + 1).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83819
[Bug 83819] [meta-bug] missing strlen optimizations

Reply via email to