|
From: Nicholas N. <nj...@ca...> - 2003-03-17 19:37:29
|
On Mon, 17 Mar 2003, Jason Evans wrote: > > But the numbers are not good, actually a performance decrease against > > switch(). > > I've recently been doing some experimentation with computed gotos in an > unrelated program, and I've also observed a slowdown in most cases. This > indicates to me that gcc typically does a fine job of optimizing switch > statements, and there isn't a whole lot to be gained by second guessing it > in such cases. I think Christian got good results with the first version, but not with the second version that computes each label address as a difference from a base label address. So it looks like it (the first version) is worthwhile. I've had mixed successes with computed gotos in the past as well... branch prediction is very important; I once tried the computed goto trick which saved me quite a few instructions, but made the branches more or less unpredictable, and the end result was little difference. N |