]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/69196 (code size regression with jump threading at -O2)
authorJeff Law <law@redhat.com>
Tue, 1 Mar 2016 21:46:58 +0000 (14:46 -0700)
committerJeff Law <law@gcc.gnu.org>
Tue, 1 Mar 2016 21:46:58 +0000 (14:46 -0700)
PR tree-optimization/69196
* tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths):
Do count some PHIs in the thread path against the insn count.  Decrease
final statement count by one as the control statement in the last
block will get removed.  Remove special cased code for handling PHIs in the last block.

PR tree-optimization/69196
* gcc.dg/tree-ssa/vrp46.c: Twiddle threading params to keep it from
duplicating code and spoiling the expected output.

From-SVN: r233866

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp46.c
gcc/tree-ssa-threadbackward.c

index b758d42656005ccfe691911b532b9d6c80494286..c1f25572590e091fbf55cf141bda48b6424a72cc 100644 (file)
@@ -1,3 +1,11 @@
+2016-03-01  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/69196
+       * tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths):
+       Do count some PHIs in the thread path against the insn count.  Decrease
+       final statement count by one as the control statement in the last
+       block will get removed.  Remove special cased code for handling PHIs            in the last block.
+
 2016-03-01  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/70027
index 000ece8b63fa01394698a4fcdeccc7486679d713..ef8a9875d4021ac3051af79f4cb55cbd4b6d1360 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-01  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/69196
+       * gcc.dg/tree-ssa/vrp46.c: Twiddle threading params to keep it from
+       duplicating code and spoiling the expected output.
+
 2016-03-01  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/70033
index 8923eb404d3df06b0e1c00b0d4cb945ed8dd289e..d3c9ed144f387cc98f549a5d0bf1b4ece89a81cb 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 --param fsm-scale-path-blocks=1" } */
 
 int func_81 (int);
 int func_98 (int);
index 55dbcaddf69f4e8e86159536c937b461a57b92b5..3028504aefa2c8e9233038f67738335ec26e8ebf 100644 (file)
@@ -286,6 +286,37 @@ fsm_find_control_statement_thread_paths (tree name,
                      break;
                    }
 
+                 /* PHIs in the path will create degenerate PHIS in the
+                    copied path which will then get propagated away, so
+                    looking at just the duplicate path the PHIs would
+                    seem unimportant.
+
+                    But those PHIs, because they're assignments to objects
+                    typically with lives that exist outside the thread path,
+                    will tend to generate PHIs (or at least new PHI arguments)
+                    at points where we leave the thread path and rejoin
+                    the original blocks.  So we do want to account for them.
+
+                    We ignore virtual PHIs.  We also ignore cases where BB
+                    has a single incoming edge.  That's the most common
+                    degenerate PHI we'll see here.  Finally we ignore PHIs
+                    that are associated with the value we're tracking as
+                    that object likely dies.  */
+                 if (EDGE_COUNT (bb->succs) > 1 && EDGE_COUNT (bb->preds) > 1)
+                   {
+                     for (gphi_iterator gsip = gsi_start_phis (bb);
+                          !gsi_end_p (gsip);
+                          gsi_next (&gsip))
+                       {
+                         gphi *phi = gsip.phi ();
+                         tree dst = gimple_phi_result (phi);
+
+                         if (SSA_NAME_VAR (dst) != SSA_NAME_VAR (name)
+                             && !virtual_operand_p (dst))
+                           ++n_insns;
+                       }
+                   }
+
                  for (gsi = gsi_after_labels (bb);
                       !gsi_end_p (gsi);
                       gsi_next_nondebug (&gsi))
@@ -324,6 +355,11 @@ fsm_find_control_statement_thread_paths (tree name,
                threaded_through_latch = true;
            }
 
+         /* We are going to remove the control statement at the end of the
+            last block in the threading path.  So don't count it against our
+            statement count.  */
+         n_insns--;
+
          gimple *stmt = get_gimple_control_stmt ((*path)[0]);
          gcc_assert (stmt);
          /* We have found a constant value for ARG.  For GIMPLE_SWITCH
@@ -352,24 +388,6 @@ fsm_find_control_statement_thread_paths (tree name,
                  == DOMST_NONDOMINATING))
            creates_irreducible_loop = true;
 
-         /* PHIs in the final target and only the final target will need
-            to be duplicated.  So only count those against the number
-            of statements.  */
-         gphi_iterator gsip;
-         for (gsip = gsi_start_phis (taken_edge->dest);
-              !gsi_end_p (gsip);
-              gsi_next (&gsip))
-           {
-             gphi *phi = gsip.phi ();
-             tree dst = gimple_phi_result (phi);
-
-             /* We consider any non-virtual PHI as a statement since it
-                count result in a constant assignment or copy
-                operation.  */
-             if (!virtual_operand_p (dst))
-               ++n_insns;
-           }
-
          if (path_crosses_loops)
            {
              if (dump_file && (dump_flags & TDF_DETAILS))