------- Additional Comments From joseph at codesourcery dot com  2005-06-10 
19:07 -------
Subject: Re:  GCC should combine adjacent stdio
 calls

On Fri, 10 Jun 2005, ghazi at gcc dot gnu dot org wrote:

> 
> ------- Additional Comments From ghazi at gcc dot gnu dot org  2005-06-10 
> 15:05 -------
> (In reply to comment #33)
> > Subject: Re:  GCC should combine adjacent stdio
> >  calls
> > On Fri, 10 Jun 2005, ghazi at gcc dot gnu dot org wrote:
> > Since putc and puts are typically faster than printf (not needing to parse 
> > the input) and we optimize printf of constants into them, it's not clear 
> > that merging printf with such functions would be an improvement either.
> 
> You're probably right that it's not a speed win, but it may be a code size 
> win 
> for -Os.  I'd like to benchmark that too if possible.

If an actual gain is demonstrated (for a reasonably large and diverse body 
of code, given that reduced code is being balanced with increased data 
because of less string sharing), and all the cases not involving printing 
data modified by printf are resolved, then it might have sense to do the 
optimizations with -fno-builtin-printf available to disable them.  It's 
still necessary to parse the format strings to make sure they are 
understood with no %n, $ operand numbers or excess arguments and to 
disallow merging where there is a store inbetween to memory which might 
either be involved in the stdio structures (the macro clearerr case) or 
which might be part of a string printed by the first printf (the example I 
gave of a local buffer printed in both the first and second printfs but 
with value changed inbetween).



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21982

Reply via email to