]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Introduce flag_cunroll_grow_size for cunroll and avoid enable it at -O2
authorguojiufu <guojiufu@linux.ibm.com>
Thu, 28 May 2020 05:42:23 +0000 (13:42 +0800)
committerguojiufu <guojiufu@linux.ibm.com>
Fri, 19 Jun 2020 06:55:07 +0000 (14:55 +0800)
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.

gcc/common.opt
gcc/config/rs6000/rs6000.c
gcc/toplev.c
gcc/tree-ssa-loop-ivcanon.c

index 65a82410abc804b2cbc335c768c8ff4d48cf8530..3ec7743eae8f61e11b7dfdf50f683ae1ddac826e 100644 (file)
@@ -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
index b4fb8b5fcfc4a507cdd6b5e722bf1321d6f00f59..860108496cc59378e6787258adda52d88693ee70 100644 (file)
@@ -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
index 5c026feece28c6527ab04459626d0376c22013d1..deccd7f15ba2a48726e95b3697725d27e0e93740 100644 (file)
@@ -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;
index 8ab6ab3330c5f7302ffddd7fc47c7b20fbed77fc..298ab2155301b08710d0be67ac63699e1748000d 100644 (file)
@@ -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);