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]

Compiling switches for bytecode interpreters


> 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  |                         |
-------------------------------------------------------------------------


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