Optimizing a Switch

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

 



Hi list,

I need to optimize a switch statement in an interpreter which is basicly :

while(true) {
  switch( *pc++ ) {
  case OPcode1:
     ....
  case opcode2:
     ....
  (more opcodes)
  }
}

I managed to store my PC into a register, so now the generated code of the
switch is the following :

L530:
     movl (%ebx), %edx
     addl $4, %ebx
     cmpl $130, %edx       // if outside of the range
     ja L530
     jmp *L384(,%edx,4)  // use jmptable

I would like to get rid of the two instructions "cmpl" and "ja" by
specifying somehow that all the cases in my switch are defined (since I'm
checking the bytecode before executing). I think MSVC have some __assume
statement for this case. Is there any GCC-specific way of doing this ?

Thanks,
Nicolas


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux