From 512328deee61568cb6bdfcd7df134d64d8889d55 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 4 Apr 2018 21:39:44 +0000 Subject: [PATCH] * include loop unrolling in -O3, as it is done carefully, it is beneficial on average git-svn-id: trunk@38687 - --- compiler/globtype.pas | 2 +- compiler/optloop.pas | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index 558e925fc0..427c3b5938 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -369,7 +369,7 @@ interface { switches being applied to all CPUs at the given level } 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,cs_opt_use_load_modify_store]; + genericlevel3optimizerswitches = [cs_opt_level3,cs_opt_constant_propagate,cs_opt_nodedfa,cs_opt_use_load_modify_store,cs_opt_loopunroll]; genericlevel4optimizerswitches = [cs_opt_level4,cs_opt_reorder_fields,cs_opt_dead_values,cs_opt_fastmath]; { whole program optimizations whose information generation requires diff --git a/compiler/optloop.pas b/compiler/optloop.pas index 43039ae938..80554c409d 100644 --- a/compiler/optloop.pas +++ b/compiler/optloop.pas @@ -141,7 +141,11 @@ unit optloop; begin replaceinfo.node:=tfornode(node).left; replaceinfo.value:=tordconstnode(tfornode(node).right).value; - end; + end + else + { we consider currently unrolling not beneficial, if we cannot get rid of the for completely, this + might change if a more sophisticated heuristics is used (FK) } + exit; { let's unroll (and rock of course) } for i:=1 to unrolls do