This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Analysis of Brad's GCSE problem with computed gotos.
- To: matzmich at cs dot tu-berlin dot de (Michael Matz)
- Subject: Re: Analysis of Brad's GCSE problem with computed gotos.
- From: Brad Lucier <lucier at math dot purdue dot edu>
- Date: Sat, 2 Dec 2000 18:36:35 -0500 (EST)
- Cc: gcc at gcc dot gnu dot org, lucier at math dot purdue dot edu (Brad Lucier), feeley at iro dot umontreal dot ca
Michael:
> This program crashes when compiled with -O2 but not with "-O2 -fno-gcse".
After thinking about your explanation, I rewrote the code to get
the following, which runs fine with -O2:
extern void abort (void);
extern void side_effect(void);
extern int ei;
extern int * get_ip ();
int main(void)
{
static void * table[] = {
&&jump2 ,&&L00, &&L11, &&L22
};
int *ip;
int e = 0, f = 0, state = 3;
goto jump;
L00:
side_effect();
L0:
f = ip[35];
goto L1;
L11:
side_effect();
L1:
e = ip[35];
goto end;
L22:
side_effect();
L2:
ip = (int*)4;
goto end;
jump2:
side_effect();
jump:
ei = 23;
ip = get_ip ();
goto *table[state];
end:
if (ip != (int*) 4 || (e+f) != 0) abort();
return 0;
}
int ei;
int * get_ip ()
{
return 0 /*&ei*/ ;
}
void side_effect(void)
{
printf("Ha\n");
}
I started off without the calls to side_effect, I just wanted to have
empty blocks in which to put instructions during PRE, but jump analysis,
run before gcse, got rid of the unused labels and edges before gcse.
I couldn't figure out how to manipulate things in toplev so that gcse was run
with the flow graph I wanted.
I was hoping to use the multiple label trick to generate code that
gets around the gcse bug, but I guess it won't work.
Brad