+ optimization setting level4

+ change tail calls into jmp if a ret without constant follows

git-svn-id: trunk@29653 -
This commit is contained in:
florian 2015-02-08 11:24:30 +00:00
parent 8de49997ea
commit 06fd4223e9
2 changed files with 44 additions and 19 deletions

View File

@ -267,7 +267,7 @@ interface
type type
{ optimizer } { optimizer }
toptimizerswitch = (cs_opt_none, 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_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_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, cs_opt_nodedfa,cs_opt_loopstrength,cs_opt_scheduler,cs_opt_autoinline,cs_useebp,cs_userbp,
@ -313,7 +313,7 @@ interface
const const
OptimizerSwitchStr : array[toptimizerswitch] of string[17] = ('', OptimizerSwitchStr : array[toptimizerswitch] of string[17] = ('',
'LEVEL1','LEVEL2','LEVEL3', 'LEVEL1','LEVEL2','LEVEL3','LEVEL4',
'REGVAR','UNCERTAIN','SIZE','STACKFRAME', 'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE', 'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE',
'DFA','STRENGTH','SCHEDULE','AUTOINLINE','USEEBP','USERBP', 'DFA','STRENGTH','SCHEDULE','AUTOINLINE','USEEBP','USERBP',
@ -345,7 +345,7 @@ interface
genericlevel1optimizerswitches = [cs_opt_level1,cs_opt_peephole]; genericlevel1optimizerswitches = [cs_opt_level1,cs_opt_peephole];
genericlevel2optimizerswitches = [cs_opt_level2,cs_opt_remove_emtpy_proc]; genericlevel2optimizerswitches = [cs_opt_level2,cs_opt_remove_emtpy_proc];
genericlevel3optimizerswitches = [cs_opt_level3,cs_opt_constant_propagate,cs_opt_nodedfa]; 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 { whole program optimizations whose information generation requires
information from all loaded units information from all loaded units

View File

@ -2331,6 +2331,7 @@ begin
end; end;
case taicpu(p).opcode Of case taicpu(p).opcode Of
A_CALL: A_CALL:
begin
{ don't do this on modern CPUs, this really hurts them due to { don't do this on modern CPUs, this really hurts them due to
broken call/ret pairing } broken call/ret pairing }
if (current_settings.optimizecputype < cpu_Pentium2) and if (current_settings.optimizecputype < cpu_Pentium2) and
@ -2346,6 +2347,30 @@ begin
taicpu(p).is_jmp := true; taicpu(p).is_jmp := true;
asml.remove(hp1); asml.remove(hp1);
hp1.free; 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; end;
A_CMP: A_CMP:
begin begin