This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize sprintf into strcpy if possible
- To: jakub at redhat dot com
- Subject: Re: [PATCH] Optimize sprintf into strcpy if possible
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Fri, 6 Apr 2001 16:43:15 -0400 (EDT)
- Cc: gcc-patches at gcc dot gnu dot org
> This patch optimizes sprintf (x, "%s", y) into strcpy (x, y) and also
> sprintf (x, "foowithoutpercentcharacter") into strcpy (x, "foo....").
One reason I didn't write this one when I initially did the stdio opts
was that I worried what happens when e.g. on older hosts sprintf is
declared in stdio.h to return char* ?
I think sunos4 is one such host, can you please test it there to make
sure it at least degrades gracefully (or perhaps make it actually
work?)
There might be some exception which allows decl conflicts for builtins
to work, I'm not sure about return types though.
Minor addition request:
You could probably add optimizing sprintf(x, "%c", c) into *x=(char)c;
using INDIRECT_REF, MODIFY_EXPR and CONVERT_EXPR to create the proper
tree expression.
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions