c/7344: performance regression on huge case statements

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


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-bugs mailing list