in the peephole optimizer by slightly modifying some function headers based
on their intended purpose, resolves#36353
* Non-virtual methods and class methods that don't need to access any fields from
the current object are now static methods, thus removing the hidden "Self"
parameter and reducing overhead. This includes a large number of
frequently-used functions such as SkipEntryExitMarker and SuperRegistersEqual.
* GetNextInstruction, GetLastInstruction, SkipEntryExitMarker and
SkipLabels have had their 'var' parameter changed to an 'out' parameter because
they shouldn't depend on its input value. This will cause the compiler to throw warnings
if you start using the value without initialising it first, and may open up optimisation
opportunities in the future (e.g. storing written values in a temporary register
and only writing it to the actual variable when the routine exits).
git-svn-id: trunk@43595 -
+ This patch serves to extend the JMP -> RET optimisation in OptPass2JMP by also doing the same
for JMP -> MOV/RET, since there are often cases where the result (e.g. EAX) is set just
prior to the function exiting.
* RemoveDeadCodeAfterJump will now drop out if it detects SEH information -
this stops exception information from being stripped if it is called on the final RET instruction.
git-svn-id: trunk@43592 -
* adds an extra optimisation to "PostPeepholeOptMov" in compiler/x86/aoptx86.pas:
If the instruction "MOV REG, -1" (Intel notation) is found, where REG is either
a 32- or 64-bit register, it is changed to "OR REG, -1" instead.
The effect is the same and takes exactly the same speed to execute, but the encoding is much smaller.
As it cause false data dependencies, it is only applied in -Os mode
For 16-bit registers, only AX is optimised this way because it has its own encoding for OR that takes fewer bytes.
git-svn-id: trunk@43579 -
* The supplied patch cleans up some vestigial code from the i386 peephole
optimizer that has since been superseded by the jump optimisations over
at #36271.
* The PrePeepholeOptsCPU method has had a minor restructuring to better
handle the rare case where InsContainsSegRef() returns True and
p becomes something that is no longer an instruction (it ultimately
removes a conditonal check and some overhead from repeated function calls).
git-svn-id: trunk@43573 -
* TAOptObj.CollapseZeroDistJump: Change hp1 to local variable,
initialized as p.next, to avoid problems of dangling pointers
revealed by use of "-CriotR -O2" compilation arguments.
git-svn-id: trunk@43554 -