From: Julian S. <js...@ac...> - 2003-03-18 08:37:24
|
[2nd try at getting this to v-users list] On Monday 17 March 2003 7:37 pm, Nicholas Nethercote wrote: > 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. The computed goto thing is useful for speeding up bytecode interpreters -- I've used it for that before now -- but this isn't such a case. It's the switch in the x86 parser which switches on the opcodes being examined. It is used only once per instruction which V translates and so the cost difference (a few host insns) must be completely swamped by the rest of the translation costs (000s of host insns per translated insn, typically). And translation costs are usually small (0-15%) compared to the cost of running the translation. So I'm mystified where the 7% speedup number comes from. J |