Commit 60bd3f20 by guojiufu

Introduce flag_cunroll_grow_size for cunroll and avoid enable it at -O2

Currently GIMPLE complete unroller(cunroll) is checking
flag_unroll_loops and flag_peel_loops to see if allow size growth.
Beside affects curnoll, flag_unroll_loops also controls RTL unroler.
To have more freedom to control cunroll and RTL unroller, this patch
introduces flag_cunroll_grow_size.  With this patch, we can control
cunroll and RTL unroller indepently. And enable flag_cunroll_grow_size
only if -funroll-loops or -fpeel-loops or -O3 is specified explicitly.

gcc/ChangeLog
2020-06-19  Jiufu Guo  <guojiufu@linux.ibm.com>

	PR target/95018
	* common.opt (flag_cunroll_grow_size): New flag.
	* toplev.c (process_options): Set flag_cunroll_grow_size.
	* tree-ssa-loop-ivcanon.c (pass_complete_unroll::execute):
	Use flag_cunroll_grow_size.
	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Override flag_cunroll_grow_size.
parent eb13d29d
......@@ -2851,6 +2851,10 @@ funroll-all-loops
Common Report Var(flag_unroll_all_loops) Optimization
Perform loop unrolling for all loops.
funroll-completely-grow-size
Undocumented Var(flag_cunroll_grow_size) Init(2) Optimization
; Internal undocumented flag, allow size growth during complete unrolling
; Nonzero means that loop optimizer may assume that the induction variables
; that control loops do not overflow and that the loops with nontrivial
; exit condition are not infinite
......
......@@ -4566,7 +4566,12 @@ rs6000_option_override_internal (bool global_init_p)
unroll_only_small_loops = 0;
if (!global_options_set.x_flag_rename_registers)
flag_rename_registers = 1;
if (!global_options_set.x_flag_cunroll_grow_size)
flag_cunroll_grow_size = 1;
}
else
if (!global_options_set.x_flag_cunroll_grow_size)
flag_cunroll_grow_size = flag_peel_loops || optimize >= 3;
/* If using typedef char *va_list, signal that
__builtin_va_start (&ap, 0) can be optimized to
......
......@@ -1474,6 +1474,11 @@ process_options (void)
if (flag_unroll_all_loops)
flag_unroll_loops = 1;
/* Allow cunroll to grow size accordingly. */
if (flag_cunroll_grow_size == AUTODETECT_VALUE)
flag_cunroll_grow_size
= flag_unroll_loops || flag_peel_loops || optimize >= 3;
/* web and rename-registers help when run after loop unrolling. */
if (flag_web == AUTODETECT_VALUE)
flag_web = flag_unroll_loops;
......
......@@ -1603,9 +1603,8 @@ pass_complete_unroll::execute (function *fun)
re-peeling the same loop multiple times. */
if (flag_peel_loops)
peeled_loops = BITMAP_ALLOC (NULL);
unsigned int val = tree_unroll_loops_completely (flag_unroll_loops
|| flag_peel_loops
|| optimize >= 3, true);
unsigned int val = tree_unroll_loops_completely (flag_cunroll_grow_size,
true);
if (peeled_loops)
{
BITMAP_FREE (peeled_loops);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment