public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC does not cope with my code
@ 2000-05-24  2:35 Gunnar Braun
  2000-05-24 11:30 ` Eric Christopher
  0 siblings, 1 reply; 5+ messages in thread
From: Gunnar Braun @ 2000-05-24  2:35 UTC (permalink / raw)
  To: gcc

Hi.

I'm currently developing tools that generate C++ code. The generated
code contains a bunch of macros which are expanded by the preprocessor.
No problem up to here. Now I'd like to compile the resulting file with
g++, but it takes ages until I get the object file. It gets worse, if I
try to optimize the code generation via -O (of course it gets). The
problem is that the (source) file (after the macro expansion) isn't
really large, it's below 700 kB. If the file gets above 700 kB, the
compiler crashes with the famous signal 11 internal compiler error.

I compiled even bigger source files with g++, so it can't be the file
size which confuses the compiler. So I end up with the following
question:

What is wrong with the generated source file that the compiler doesn't
cope with it?

or:

What changes can I apply to the _code_ to reduce compile time/make it
possible to compile the file?

I used gcc version 2.95.2 on a Sparc ULTRA-10 running Solaris 2.7. I
attached an extract of the file I'd like to compile to this posting.

I would appreciate if anybody had an idea about that!

Greetings,

Gunnar
//
// The file mainly looks like the following lines:
//

void ARM7_model::execute_program_block_005()
{
  register long oldPC;
  switch(PC)
    {
    case 0x00001798: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0    , 0    , 0    ); }  ; }     ; {  ; { R[0x3]     = barrel_shifter_operand2_bus; if (& R[0x3]     == &R[15]) R[0x3]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x0000179c: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x3]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017a0: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x0000004c    , 0    , 0    ); }  ; }     ; {  ; { R[0x3]     = add_val(R[0xd]    , barrel_shifter_operand2_bus, 0, 0    );	if (& R[0x3]     == &R[15]) R[0x3]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017a4: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x0000001c    , 0    , 0    ); }  ; }     ; {  ; { R[0x2]     = barrel_shifter_operand2_bus; if (& R[0x2]     == &R[15]) R[0x2]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017a8: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x00000064    , 0    , 0    ); }  ; }     ; {  ; { R[0x1]     = barrel_shifter_operand2_bus; if (& R[0x1]     == &R[15]) R[0x1]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017ac: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x0000000b    , 0    , 0    ); }  ; }     ; {  ; { R[0x0]     = barrel_shifter_operand2_bus; if (& R[0x0]     == &R[15]) R[0x0]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017b0: oldPC = PC; {  ; { instruction_counter++; {  ; { R[14] = PC + 4; PC += ((signed int )(( (0x000009d4     << 2) ) << (32-( 26 ))) >> (32-( 26 )))  + 4; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017b4: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0    ; }  ; }     ; {  ; { address_bus = R[0x4]     + offset_bus; }  ; }     ; {  ; { store_byte(address_bus,R[0x5]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017b8: oldPC = PC; {  ; { instruction_counter++; {  ; { PC += ((signed int )(( (0x00ffff90     << 2) ) << (32-( 26 ))) >> (32-( 26 )))  + 4; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017bc: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x000003f0    ; }  ; }     ; {  ; { address_bus = R[0x3]     - offset_bus; }  ; }     ; {  ; { load_word(address_bus,R[0x0]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017c0: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0    , 0    , 1    ); }  ; }     ; {  ; { unsigned int  test_and; test_and = sub_val(R[0x0]    , barrel_shifter_operand2_bus, 0, 1    );	if (&test_and == &R[15]) test_and -=4; update_cpsr_lu(test_and); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017c4: oldPC = PC; {  ; { instruction_counter++; if(((CPSR & 0x40000000) == 0x40000000) ) {  ; { PC += ((signed int )(( (0x00000028     << 2) ) << (32-( 26 ))) >> (32-( 26 )))  + 4; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017c8: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x00000001    , 0    , 1    ); }  ; }     ; {  ; { R[0x0]     = sub_val(R[0x0]    , barrel_shifter_operand2_bus,0, 1    );	if (& R[0x0]     == &R[15]) R[0x0]     -=4; update_cpsr_lu(R[0x0]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017cc: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x000003f0    ; }  ; }     ; {  ; { address_bus = R[0x3]     - offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x0]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017d0: oldPC = PC; {  ; { instruction_counter++; if(! ((CPSR & 0x40000000) == 0x40000000) ) {  ; { PC += ((signed int )(( (0x00000025     << 2) ) << (32-( 26 ))) >> (32-( 26 )))  + 4; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017d4: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x0000002c    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x1]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017d8: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000030    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0xe]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017dc: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000034    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x1]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017e0: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000038    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x1]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017e4: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x0000003c    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0xc]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017e8: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000040    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x2]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017ec: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000044    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x2]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017f0: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000048    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x2]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017f4: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x0000004c    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x1]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017f8: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000050    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x5]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x000017fc: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x00000003    , 0    , 0    ); }  ; }     ; {  ; { R[0x0]     = barrel_shifter_operand2_bus; if (& R[0x0]     == &R[15]) R[0x0]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001800: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000054    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x0]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001804: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x00000005    , 0    , 0    ); }  ; }     ; {  ; { R[0x0]     = barrel_shifter_operand2_bus; if (& R[0x0]     == &R[15]) R[0x0]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001808: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000058    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x0]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x0000180c: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x00000007    , 0    , 0    ); }  ; }     ; {  ; { R[0x0]     = barrel_shifter_operand2_bus; if (& R[0x0]     == &R[15]) R[0x0]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001810: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x0000005c    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0x0]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001814: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000060    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0xc]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001818: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0x00000064    ; }  ; }     ; {  ; { address_bus = R[0xd]     + offset_bus; }  ; }     ; {  ; { store_word(address_bus,R[0xc]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x0000181c: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x0000002c    , 0    , 0    ); }  ; }     ; {  ; { R[0x0]     = add_val(R[0xd]    , barrel_shifter_operand2_bus, 0, 0    );	if (& R[0x0]     == &R[15]) R[0x0]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001820: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x00000010    , 0    , 0    ); }  ; }     ; {  ; { R[0x1]     = add_val(R[0x0]    , barrel_shifter_operand2_bus, 0, 0    );	if (& R[0x1]     == &R[15]) R[0x1]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001824: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { {  ; { barrel_shifter_operand2_bus = imm_lsl(R[0xd]    , 0    , 0    ); }  ; }     ; }  ; }     ; {  ; { R[0x0]     = barrel_shifter_operand2_bus; if (& R[0x0]     == &R[15]) R[0x0]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001828: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x0000002c    , 0    , 0    ); }  ; }     ; {  ; { R[0x2]     = barrel_shifter_operand2_bus; if (& R[0x2]     == &R[15]) R[0x2]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x0000182c: oldPC = PC; {  ; { instruction_counter++; {  ; { R[14] = PC + 4; PC += ((signed int )(( (0x000023a8     << 2) ) << (32-( 26 ))) >> (32-( 26 )))  + 4; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001830: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { barrel_shifter_operand2_bus = rot_imm(0x0000002c    , 0    , 0    ); }  ; }     ; {  ; { R[0x3]     = add_val(R[0xd]    , barrel_shifter_operand2_bus, 0, 0    );	if (& R[0x3]     == &R[15]) R[0x3]     -=4; }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001834: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { unsigned int*  save_register[16]; int current_pos = 0; if(0x00000001    ) save_register[current_pos++] = &R[0]; if(0x00000001    ) save_register[current_pos++] = &R[1]; if(0x00000001    ) save_register[current_pos++] = &R[2]; if(0x00000001    ) save_register[current_pos++] = &R[3]; if(0    ) save_register[current_pos++] = &R[4]; if(0    ) save_register[current_pos++] = &R[5]; if(0    ) save_register[current_pos++] = &R[6]; if(0    ) save_register[current_pos++] = &R[7]; if(0    ) save_register[current_pos++] = &R[8]; if(0    ) save_register[current_pos++] = &R[9]; if(0    ) save_register[current_pos++] = &R[10]; if(0    ) save_register[current_pos++] = &R[11]; if(0    ) save_register[current_pos++] = &R[12]; if(0    ) save_register[current_pos++] = &R[13]; if(0    ) save_register[current_pos++] = &R[14]; if(0    ) save_register[current_pos++] = &R[15]; for(int i=0; i < current_pos; i++) { reg = save_register[i]; address_bus = R[0x3]     + (4*i); {  ; { load_word(address_bus,*reg); }  ; }     ; } }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x00001838: oldPC = PC; {  ; { instruction_counter++; {  ; { R[14] = PC + 4; PC += ((signed int )(( (0x00fffde0     << 2) ) << (32-( 26 ))) >> (32-( 26 )))  + 4; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;
    case 0x0000183c: oldPC = PC; {  ; { instruction_counter++; {  ; { {  ; { offset_bus = 0    ; }  ; }     ; {  ; { address_bus = R[0x4]     + offset_bus; }  ; }     ; {  ; { load_byte(address_bus,R[0x5]    ); }  ; }     ; }  ; }     ; }  ; }    ; cycle++; PC += 4; if (PC != (oldPC + 4)) break;

      //
      // ... and so on up to a total file size of about 700 kB.
      //

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC does not cope with my code
  2000-05-24  2:35 GCC does not cope with my code Gunnar Braun
@ 2000-05-24 11:30 ` Eric Christopher
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Christopher @ 2000-05-24 11:30 UTC (permalink / raw)
  To: Gunnar Braun; +Cc: gcc

> I'm currently developing tools that generate C++ code. The generated
> code contains a bunch of macros which are expanded by the preprocessor.
> No problem up to here. Now I'd like to compile the resulting file with
> g++, but it takes ages until I get the object file. It gets worse, if I
> try to optimize the code generation via -O (of course it gets). The
> problem is that the (source) file (after the macro expansion) isn't
> really large, it's below 700 kB. If the file gets above 700 kB, the
> compiler crashes with the famous signal 11 internal compiler error.
> 
> What is wrong with the generated source file that the compiler doesn't
> cope with it?

Nothing is wrong per se, but the switch statements are really large. 
Especially in the optimized case it is allocating huge vectors of
memory. 

> 
> or:
> 
> What changes can I apply to the _code_ to reduce compile time/make it
> possible to compile the file?
> 

Break up the switch statements if possible.  Break them into functions
and then have smaller switch statements inside would be an idea.

-eric

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC does not cope with my code
  2000-05-30  6:03 ` Alexandre Oliva
@ 2000-05-30  9:21   ` Colin Howell
  0 siblings, 0 replies; 5+ messages in thread
From: Colin Howell @ 2000-05-30  9:21 UTC (permalink / raw)
  To: Gunnar Braun; +Cc: Alexandre Oliva, gcc

Alexandre Oliva <aoliva@cygnus.com> writes:

> On May 30, 2000, Gunnar Braun <braung@ert.rwth-aachen.de> wrote:
> 
> > I think the compiler (or better the optimizer) has internal limits
> > concerning the memory allocation, since the memory of my system
> > should be sufficient (1GB real + 4 GB swap memory).
> 
> I doubt it.  On some systems, the per-process memory is limited.

Specifically, Gunnar, I think you're probably running into the stack
limit.  Unix systems normally have separate limits for the amount of
data and stack space used by a process, and the stack limit is
generally the more restrictive of these.  It also is the one most
likely to cause GCC to get a SIG11.  If you hit the data limit, GCC
would abort with a different sort of error (such as "Virtual memory
exhausted") when it attempted to allocate a data structure.  But when
GCC hits the stack limit, it may abort with SIG11 while trying to
access something on the stack.

You could increase the stack limit for your processes (see "man limit"
for details on how to do this), but it seems like restructuring your
code might be a better way to go.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC does not cope with my code
  2000-05-30  0:28 Gunnar Braun
@ 2000-05-30  6:03 ` Alexandre Oliva
  2000-05-30  9:21   ` Colin Howell
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Oliva @ 2000-05-30  6:03 UTC (permalink / raw)
  To: Gunnar Braun; +Cc: gcc

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

On May 30, 2000, Gunnar Braun <braung@ert.rwth-aachen.de> wrote:

> I think the compiler (or better the optimizer) has internal limits
> concerning the memory allocation, since the memory of my system
> should be sufficient (1GB real + 4 GB swap memory).

I doubt it.  On some systems, the per-process memory is limited.

> So long and thanks for all the fish,

:-)

-- 
Alexandre Oliva    Enjoy Guaraná, see http://www.ic.unicamp.br/~oliva/
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC does not cope with my code
@ 2000-05-30  0:28 Gunnar Braun
  2000-05-30  6:03 ` Alexandre Oliva
  0 siblings, 1 reply; 5+ messages in thread
From: Gunnar Braun @ 2000-05-30  0:28 UTC (permalink / raw)
  To: gcc

Hi.

First of all, thanks for all the responses to my posting. I received
lots of answers to my question and they were all quite helpful.

The most frequent opinion was that the main function containing the big
switch statement was simply too large, since most compiler optimize
function-wise, an so the memory demand grows up with the power of 2 or
even more. That was probably the cause of the SIG11 crash. I think the
compiler (or better the optimizer) has internal limits concerning the
memory allocation, since the memory of my system should be sufficient
(1GB real + 4 GB swap memory).

So I broke up that function into small pieces which was gladly accepted
by the compiler. I pursued two approches: a) to generate one function
for each case in the switch statement and b) to split the statement into
blocks of about 300 cases and then call one function for each block. The
second approch turned out to be the faster one (which is pretty
important for me, since I am - as you might have guessed - generating
fast processor simulators out of a processor description *). So I think
Paolo's idea would be fastest solution.

Furthermore, most of you discovered the useless PC
increment/decrement/comparision. Surely, you are right, but
unfortunately that's a think I can't change, since that's up to the guy
who did the processor description. It's my job to get the best out of
it, but of course I can't generate nice, clean, highly optimized C++
code out of it.

I received lots of useful ideas I'm currently "playing" with I didn't
even considered before.

So long and thanks for all the fish,

Gunnar

*) See http://www.ert.rwth-aachen.de/lisa if you like

PS: A switch-case statment does _not_ behave like if-else with lots of
comparisions. The compiler generates a kind of function table containing
all the cases and then uses a map function to switch to a particular
case in the table. So it is *much* faster that if-else and almost as
fast as building up such a funtion table by hand.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-05-30  9:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-24  2:35 GCC does not cope with my code Gunnar Braun
2000-05-24 11:30 ` Eric Christopher
2000-05-30  0:28 Gunnar Braun
2000-05-30  6:03 ` Alexandre Oliva
2000-05-30  9:21   ` Colin Howell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).