lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


For the (very first and orgiinal :) ) ARM C compiler I wrote while at Acorn back in 1988, I implemented table-of-addresses (actually, it would analyse all the values for sufficient-dense areas, filling in any holes with jumps to the default case if that would make them dense enough, then test-and-branch if necessary to the mulitple TOAs)

Because it's possible on the ARM, the TOAs actually contained jump instructions, not just the address, so the code jumped to the right entry in the table and then jumped to the right address.

I didn't think I was being particularly sophisticated then, and I'm sure the state of the art has advanced in the 22 years since then.

So I agree, I see nothing in C switch statements that makes them inherently slow.

Paul
On 18 November 2010 13:37, David Kastrup <dak@gnu.org> wrote:
Alex Queiroz <asandroq@gmail.com> writes:

> On Thu, Nov 18, 2010 at 11:29 AM, David Kastrup <dak@gnu.org> wrote:
>>
>>> This code kills the CPU predictor and causes severe pipeline flushing.
>>
>> I have yet to see an alternative that can predict the opcodes.
>>
>
>      If you don't need to stick to ANSI C you can use GCC's
> first-class labels and goto. It helps the CPU a lot.

I don't see how or why.

--
David Kastrup