This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21982] GCC should combine adjacent stdio calls
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jun 2005 19:07:33 -0000
- Subject: [Bug tree-optimization/21982] GCC should combine adjacent stdio calls
- References: <20050609125653.21982.ghazi@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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