This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to add builtin strncmp and builtin strncpy
- To: rth at redhat dot com
- Subject: Re: Patch to add builtin strncmp and builtin strncpy
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Mon, 27 Nov 2000 14:31:49 -0500 (EST)
- Cc: gcc-patches at gcc dot gnu dot org, jakub at redhat dot com, jsm28 at cam dot ac dot uk
> From: Richard Henderson <rth@redhat.com>
>
> On Mon, Nov 27, 2000 at 10:49:55AM -0500, Kaveh R. Ghazi wrote:
> > Strange, it seemed to pass the testcases perhaps because I passed in
> > the target/mode from the original call.
>
> It would be truncated back down to a const_int unless you
> are cross-compiling to a larger word machine.
>
> > + /* OK transform into builtin memcpy. */
> > + return expand_builtin_memcpy (arglist);
>
> This won't result in a call to memcpy if the builtin expansion
> fails, will it?
> r~
It won't call memcpy if the expansion fails. In that case,
expand_builtin_memcpy will return a 0, which when passed back through
expand_builtin_strncpy causes the original call to strncpy to be
issued.
(It might however call memcpy if the expansion succeeds and
emit_block_move decides it can't move by pieces. But that's OK given
the constraints under which expand_builtin_memcpy is called here.)
I haven't actually tested this specific scenario though.
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions