c/7344: performance regression on huge case statements

Michael Matz matz@suse.de
Thu Oct 17 06:26:00 GMT 2002


The following reply was made to PR c/7344; it has been noted by GNATS.

From: Michael Matz <matz@suse.de>
To: Nathanael Nerode <neroden@twcny.rr.com>
Cc: <gcc-gnats@gcc.gnu.org>, <rschiele@uni-mannheim.de>,
	<gcc-bugs@gcc.gnu.org>, <nobody@gcc.gnu.org>
Subject: Re: c/7344: performance regression on huge case statements
Date: Thu, 17 Oct 2002 15:19:30 +0200 (CEST)

 Hi,
 
 On Thu, 17 Oct 2002, Nathanael Nerode wrote:
 
 > What should we do for a test case here?  I feel that it should have one,
 > but the minimal testcase is *inherently* 239K, so I'm not quite sure
 > what to do here.
 
 Nah.  One can reduce that with preprocessor magic, just like e.g.
 20001226-1.c.  E.g. to produce 64 lines (the testcase has 10000), we would
 do:
 
 #define M(x) case x: f(); goto c;
 #define M4(x) M(x) M(x+1) M(x+2) M(x+3)
 #define M16(x) M4(x) M4(x+4) M4(x+8) M4(x+12)
 #define M64(x) M16(x) M16(x+16) M16(x+32) M16(x+48)
 
 void f();
 void a()
 {
   int b;
 c: switch (b) {
   M64(1)
 }
 }
 
 
 Ciao,
 Michael.
 



More information about the Gcc-prs mailing list