+ introduce -Oofastmath

* limit the application of the tree transformation introduced in r21986 to safe cases and -Oofastmath

git-svn-id: trunk@22040 -
This commit is contained in:
florian 2012-08-08 19:35:45 +00:00
parent 8fd84376d7
commit b330bba0bc
11 changed files with 27 additions and 13 deletions

View File

@ -1081,7 +1081,7 @@ Const
{ no need to write info about those }
[cs_opt_level1,cs_opt_level2,cs_opt_level3]+
[cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields];
cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = genericlevel1optimizerswitches;
level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +

View File

@ -188,7 +188,7 @@ Const
{ no need to write info about those }
[cs_opt_level1,cs_opt_level2,cs_opt_level3]+
[cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields];
cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
cpuflagsstr : array[tcpuflags] of string[20] =
('AVR_HAS_JMP_CALL',
'AVR_HAS_MOVW',

View File

@ -244,7 +244,7 @@ interface
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_opt_reorder_fields
cs_opt_reorder_fields,cs_opt_fastmath
);
toptimizerswitches = set of toptimizerswitch;
@ -269,7 +269,7 @@ interface
'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE',
'DFA','STRENGTH','SCHEDULE','AUTOINLINE','USEEBP',
'ORDERFIELDS'
'ORDERFIELDS','FASTMATH'
);
WPOptimizerSwitchStr : array [twpoptimizerswitch] of string[14] = (
'DEVIRTCALLS','OPTVMTS','SYMBOLLIVENESS'

View File

@ -103,7 +103,7 @@ Const
[cs_opt_peephole,cs_opt_regvar,cs_opt_stackframe,
cs_opt_asmcse,cs_opt_loopunroll,cs_opt_uncertain,
cs_opt_tailrecursion,cs_opt_nodecse,cs_useebp,
cs_opt_reorder_fields];
cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = genericlevel1optimizerswitches + [cs_opt_peephole];
level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +

View File

@ -76,7 +76,7 @@ Const
{ no need to write info about those }
[cs_opt_level1,cs_opt_level2,cs_opt_level3]+
[cs_opt_regvar,cs_opt_loopunroll,cs_opt_nodecse,
cs_opt_reorder_fields];
cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = genericlevel1optimizerswitches;
level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +

View File

@ -69,7 +69,7 @@ Const
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll,cs_opt_nodecse,
cs_opt_reorder_fields];
cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = [];
level2optimizerswitches = level1optimizerswitches + [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse];

View File

@ -50,7 +50,7 @@ unit optcse;
implementation
uses
globtype,
globtype,globals,
cclasses,
verbose,
nutils,
@ -249,7 +249,21 @@ unit optcse;
B C
Because A could be another tree of this kind, the whole process is done in a while loop
}
if (n.nodetype in [andn,orn,addn,muln]) then
if (n.nodetype in [andn,orn,addn,muln]) and
(n.nodetype=tbinarynode(n).left.nodetype) and
{ do is optimizations only for integers, reals (no currency!), vectors and sets }
(is_integer(n.resultdef) or is_real(n.resultdef) or is_vector(n.resultdef) or is_set(n.resultdef)) and
{ either if fastmath is on }
((cs_opt_fastmath in current_settings.optimizerswitches) or
{ or for the logical operators, they cannot overflow }
(n.nodetype in [andn,orn]) or
{ or for integers if range checking is off }
((is_integer(n.resultdef) and
(n.localswitches*[cs_check_range,cs_check_overflow]=[]) and
(tbinarynode(n).left.localswitches*[cs_check_range,cs_check_overflow]=[]))) or
{ for sets, we can do this always }
(is_set(n.resultdef))
) then
while n.nodetype=tbinarynode(n).left.nodetype do
begin
csedomain:=true;

View File

@ -78,7 +78,7 @@ Const
{ no need to write info about those }
[cs_opt_level1,cs_opt_level2,cs_opt_level3]+
[cs_opt_regvar,cs_opt_loopunroll,cs_opt_nodecse,
cs_opt_tailrecursion,cs_opt_reorder_fields];
cs_opt_tailrecursion,cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = genericlevel1optimizerswitches;
level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + [cs_opt_regvar,cs_opt_nodecse,cs_opt_tailrecursion];

View File

@ -70,7 +70,7 @@ const
{ no need to write info about those }
[cs_opt_level1,cs_opt_level2,cs_opt_level3]+
[cs_opt_regvar,cs_opt_loopunroll,cs_opt_nodecse,
cs_opt_tailrecursion,cs_opt_reorder_fields];
cs_opt_tailrecursion,cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = genericlevel1optimizerswitches;
level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +

View File

@ -78,7 +78,7 @@ const
[cs_opt_level1,cs_opt_level2,cs_opt_level3]+
[cs_opt_regvar,cs_opt_loopunroll,
cs_opt_tailrecursion,cs_opt_nodecse,
cs_opt_reorder_fields];
cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = genericlevel1optimizerswitches;
level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +

View File

@ -91,7 +91,7 @@ Const
{ no need to write info about those }
[cs_opt_level1,cs_opt_level2,cs_opt_level3]+
[cs_opt_regvar,cs_opt_loopunroll,cs_opt_stackframe,
cs_opt_tailrecursion,cs_opt_nodecse,cs_opt_reorder_fields];
cs_opt_tailrecursion,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
level1optimizerswitches = genericlevel1optimizerswitches;
level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +