------- 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