This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEAD code

highlighted code

code is being generated by the compiler for all switch statements when the level of optimization is lower than Level 4, that DOES NOT EXECUTE. i'm not concerned with eliminating it, which is obviously accomplished by increasing the level of optimization, but i need to know why it's there??????

eg. This is an example of the disassembly associated with a switch statement when optimization set at Level 1...

switch (x)
C:0x0013 E508 MOV A,0x08
C:0x0015 120039 LCALL C?CCASE(C:0039)
C:0x0018 00 NOP
C:0x0019 36 ADDC A,@R0
C:0x001A 00 NOP
C:0x001B 00 NOP
C:0x001C 36 ADDC A,@R0
C:0x001D 00 NOP
C:0x001F 00 NOP
C:0x0021 22 RET
{
case 0:
do something
case 1:
do something

.....etc.

default:

}
the code lines C:0x0018 - C:0x0021 never execute. the call to library function C?CCASE determines where to jump and these lines are always skipped. why are they inserted by the compiler????

tim

0