mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-20 12:49:08 +02:00
+ optimization setting level4
+ change tail calls into jmp if a ret without constant follows git-svn-id: trunk@29653 -
This commit is contained in:
parent
8de49997ea
commit
06fd4223e9
@ -267,7 +267,7 @@ interface
|
||||
type
|
||||
{ optimizer }
|
||||
toptimizerswitch = (cs_opt_none,
|
||||
cs_opt_level1,cs_opt_level2,cs_opt_level3,
|
||||
cs_opt_level1,cs_opt_level2,cs_opt_level3,cs_opt_level4,
|
||||
cs_opt_regvar,cs_opt_uncertain,cs_opt_size,cs_opt_stackframe,
|
||||
cs_opt_peephole,cs_opt_asmcse,cs_opt_loopunroll,cs_opt_tailrecursion,cs_opt_nodecse,
|
||||
cs_opt_nodedfa,cs_opt_loopstrength,cs_opt_scheduler,cs_opt_autoinline,cs_useebp,cs_userbp,
|
||||
@ -313,7 +313,7 @@ interface
|
||||
|
||||
const
|
||||
OptimizerSwitchStr : array[toptimizerswitch] of string[17] = ('',
|
||||
'LEVEL1','LEVEL2','LEVEL3',
|
||||
'LEVEL1','LEVEL2','LEVEL3','LEVEL4',
|
||||
'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
|
||||
'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE',
|
||||
'DFA','STRENGTH','SCHEDULE','AUTOINLINE','USEEBP','USERBP',
|
||||
@ -345,7 +345,7 @@ interface
|
||||
genericlevel1optimizerswitches = [cs_opt_level1,cs_opt_peephole];
|
||||
genericlevel2optimizerswitches = [cs_opt_level2,cs_opt_remove_emtpy_proc];
|
||||
genericlevel3optimizerswitches = [cs_opt_level3,cs_opt_constant_propagate,cs_opt_nodedfa];
|
||||
genericlevel4optimizerswitches = [cs_opt_reorder_fields,cs_opt_dead_values,cs_opt_fastmath];
|
||||
genericlevel4optimizerswitches = [cs_opt_level4,cs_opt_reorder_fields,cs_opt_dead_values,cs_opt_fastmath];
|
||||
|
||||
{ whole program optimizations whose information generation requires
|
||||
information from all loaded units
|
||||
|
@ -2331,6 +2331,7 @@ begin
|
||||
end;
|
||||
case taicpu(p).opcode Of
|
||||
A_CALL:
|
||||
begin
|
||||
{ don't do this on modern CPUs, this really hurts them due to
|
||||
broken call/ret pairing }
|
||||
if (current_settings.optimizecputype < cpu_Pentium2) and
|
||||
@ -2346,6 +2347,30 @@ begin
|
||||
taicpu(p).is_jmp := true;
|
||||
asml.remove(hp1);
|
||||
hp1.free;
|
||||
end
|
||||
{ replace
|
||||
call procname
|
||||
ret
|
||||
by
|
||||
jmp procname
|
||||
|
||||
this should never hurt except when pic is used, not sure
|
||||
how to handle it then
|
||||
|
||||
but do it only on level 4 because it destroys stack back traces
|
||||
}
|
||||
else if (cs_opt_level4 in current_settings.optimizerswitches) and
|
||||
not(cs_create_pic in current_settings.moduleswitches) and
|
||||
GetNextInstruction(p, hp1) and
|
||||
(hp1.typ = ait_instruction) and
|
||||
(taicpu(hp1).opcode = A_RET) and
|
||||
(taicpu(hp1).ops=0) then
|
||||
begin
|
||||
taicpu(p).opcode := A_JMP;
|
||||
taicpu(p).is_jmp := true;
|
||||
asml.remove(hp1);
|
||||
hp1.free;
|
||||
end;
|
||||
end;
|
||||
A_CMP:
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user