This is the mail archive of the
mailing list for the GCC project.
Re: strlen optimizations based on whether stpcpy is declared?
On Mon, Oct 02, 2017 at 11:45:24AM -0600, Martin Sebor wrote:
> What's more, in strict mode GCC transforms stpcpy calls to strcpy.
Only if the result is not needed or if the length of the source string
is already known. And we do that transformation regardless of strict
mode. If the result is needed, I don't believe
we ever do that, it would be a clear opposite of optimization,
replace one call that does both the copying and computing the length
(well, end address, but that is simple pointer arithmetics away from that)
to computing the length one way and copying another way.
This is different for mempcpy where the result can be computed quite cheaply
and thus what kind of builtin is used doesn't matter that much, only that
we shouldn't introduce a less standard call when more standard one was used
in the source.