This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Preparsing sprintf format strings


"Heikki Linnakangas" <heikki@enterprisedb.com> writes:

> I don't have much experience with GCC hacking, but I did put together a
> prototype to do some of the above, and it does look like you can get
> very significant speedups. Before I continue with that, has something
> like this been proposed before? I couldn't find anything relevant in the
> archives.

I don't recall ever seeing anything like this, and it seems worth
pursuing.

I think it might have to be optional, unfortunately.  Otherwise, a
program which really does have to call sprintf would get larger if
some other sprintf calls are converted to calls to internal gcc
functions.  But if the program doesn't have to call sprintf anywhere,
then this optimization would make the overall program smaller.  So
when program size is the primary optimization target, I see no way to
tell a priori which approach is best.  (We could reliably tell which
is best if the real sprintf called the same set of functions which gcc
would call when it knew the format string.  Unfortunately those
functions are non-standard, so I don't see how to make that happen.)

Obviously the same types of optimizations can be applied to printf.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]