Page 1 of 1
PB4 final - ASM Output (unneeded jmp?)
Posted: Tue May 23, 2006 12:57 pm
by va!n
I noticed following while taking a clother look to the created ASM output when using procedures:
Code: Select all
... code ...
JMP _EndProcedure9
; EndProcedure
XOR eax,eax ; <<< this will never be called, so we can save the JMP
_EndProcedure9:
RET 4
whats the reason for it? (small mistake?) what about changing to...
Code: Select all
... code ...
; JMP _EndProcedure9
; EndProcedure
; XOR eax,eax
; _EndProcedure9:
RET 4
Seems this happens to any procedure you are using! o_O
Posted: Tue May 23, 2006 1:21 pm
by Deeem2031
Its the same like in 3.94. If you use ProcedureReturn at the end of the procedure it JMPs to the end to avoid reseting eax. Because if you don't use ProcedureReturn at the end it must always return 0. (Of course its the same with strings)
So its just a thing what could be optimized, but it isn't a bug.
My Optimizer for 3.94 removed this JMP if its possible. Fred said he would include a optimize-interface for the compiler to let dlls optimize the asm-output so i didn't tried to convert the Optimizer for 4.0. Fred - whats with the interface?

Posted: Tue May 23, 2006 3:37 pm
by Trond
How much is one unneeded jump. Take a look at this:
Code: Select all
; If - (Not #False)
JMP No0
XOR eax,eax ; Never reached
JMP Ok0 ; Never reached
No0:
MOV eax,1
Ok0:
MOV ebx,eax ; Moving 1 into eax, then eax into ebx, then negating ebx instead of moving 0 into ebx!
NEG ebx
AND ebx,ebx
JE _EndIf2
; Debug 1
; EndIf
_EndIf2:
That's 7 unneccessary instructions. It could all have been simplified into the single "Debug 1" statement.
But personally I think it's worse that this gives a compiles without errors:
Code: Select all
If And Not Not And Or Not And Or Not And
Debug 1
EndIf
And we have a problem here:
Code: Select all
If #False = Not(#True)
Debug 1
EndIf
Posted: Tue May 23, 2006 4:06 pm
by Fred
About the extra jump, it is still here because it is not that easy to remove it without ugly tricks in the compiler pipeline.
BTW, a compiler isn't here to optimize bad codes. If it can be simplified, just do it.
Posted: Tue May 23, 2006 4:20 pm
by va!n
@Deeem2031:
I have searched the announced (optimizer) plugin interface too but seems its sadly not included to v4 final. the only available switches are:
/CONSTANT /IGNORERESIDENT /LINKER /VERSION /UNICODE /THREAD /LINENUMBERING /DYNAMICCPU /SSE2 /SSE /3DNOW /MMX /CONSOLE /DLL /INLINEASM /SUBSYSTEM /RESOURCE /RESIDENT /XP /REASM /QUIET /ICON /EXE /DEBUGGER /COMMENTED /STANDBY
Btw, Deeem2031: how is your project going on? (i think you know what i am talking about ^^) have a nice day