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: "ghazi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jun 2005 17:02:28 -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 ghazi at gcc dot gnu dot org 2005-06-09 17:02 -------
(In reply to comment #10)
> Subject: Re: GCC should combine adjacent stdio calls
> But remember that we are not optimizing C, we are optimizing
> GIMPLE. And in GIMPLE we don't have those problems. Here's what
> the tree optimizers see:
> i_3 = i_1 + 1;
> printf (&"%d"[0], i_1);
> printf (&"%d"[0], i_3);
> Those two calls to printf can be merged. The order of evaluation
> has been decided by the gimplifier. Whether that's right or
> wrong for C, I couldn't say, all I know is that for the
> optimizers, those two printf calls look mergeable.
> Diego.
Ah okay thanks.
By the way, you may recall you and I discussed doing this during the first GCC
summit. One suggestion that IIRC Paul Brook had was to move printf statements
around to create more opportunities for combination if the intervening
statements didn't interact with the moving printf. E.g.
int i=0, j=2;
printf("%d", i);
j++;
printf("%d", j);
Pushing the first printf further down, this could be reordered as:
int i=0, j=2;
j++;
printf("%d", i);
printf("%d", j);
which would expose another combination possibility.
Paul seemed to think this wasn't hard with the existing infrastructure, and
that was two years ago.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21982