This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Compiling switches for bytecode interpreters
- To: Reuben dot Thomas at cl dot cam dot ac dot uk
- Subject: Compiling switches for bytecode interpreters
- From: John Wehle <john at feith dot com>
- Date: Tue, 2 Nov 1999 14:28:55 -0500 (EST)
- Cc: egcs at egcs dot cygnus dot com
> A simple optimisation which could benefit a range of widely-used bytecode
> interpreters (such as those for Perl and Python), and hence many users of
> systems other than GCC, would be to omit the range check on the switch
> value when it is known to be within the limits of a lookup table already
> generated for a switch. For example:
>
> switch ((byte)opcode) { ... }
>
> In this case, opcode is known to be a byte. There's probably a case for
> every possible byte in the switch, so GCC will compile a lookup table.
> There's now no point making a redundant range check.
I have a prototype of a value range pass up and running which does these
types of optimizations. I'm working on (as time allows) getting it into
shape for submission.
-- John
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------