This is the mail archive of the gcc@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]

Re: GCC does not cope with my code


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.

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