This is the mail archive of the gcc-patches@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: [PATCH] Move printf and fprintf builtins to middle-end.


 > From: Jakub Jelinek <jakub@redhat.com>
 > 
 > On Mon, Jul 21, 2003 at 11:21:46AM -0400, Kaveh R. Ghazi wrote:
 > > 	#include <stdio.h>
 > > 	int main()
 > > 	{
 > > 	#ifdef OPT
 > > 	  printf ("error1 message xyz at f.c:9\n");
 > > 	  printf ("error2 message xyz at f.c:10\n");
 > > 	  printf ("error3 message xyz at f.c:11\n");
 > > 	#else
 > > 	  printf ("error1 message xyz at %s:%d\n", __FILE__, __LINE__);
 > > 	  printf ("error2 message xyz at %s:%d\n", __FILE__, __LINE__);
 > > 	  printf ("error3 message xyz at %s:%d\n", __FILE__, __LINE__);
 > > 	#endif  
 > > 	  return 0;
 > > 	}
 > > 
 > > On sparc-sun-solaris2.7, with "-m64 -O2" with the "size" program I
 > > normally get 3134 bytes.  When I compile with -DOPT, I get 3048 for a
 > > *savings* of 86 bytes in this one case.  Note we're saving mainly code
 > > (.text) size here.
 > 
 > If s/error[123]/error/ in your testcase above, -O2 -n IA-32, I get
 > 108 bytes without -DOPT in .text+.rodata.str1.1 sections, while
 > 133 bytes with -DOPT.

Agreed, I admitted in my previous message that I skewed the case back
in favor of my point, just as your example is skewed in favor of
yours.

All this means is that after we write the optimization, we have to
look at real-life code and see whether on average we have a net win or
not.  And whether we can mitigate the losing cases through some
heuristics.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


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