common.opt (ftree-coalesce-inlined-vars): New.
authorAlexandre Oliva <aoliva@redhat.com>
Wed, 13 Jun 2012 20:41:41 +0000 (20:41 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Wed, 13 Jun 2012 20:41:41 +0000 (20:41 +0000)
gcc/ChangeLog:
* common.opt (ftree-coalesce-inlined-vars): New.
(ftree-coalesce-vars): New.
* doc/invoke.texi: Document them.
* tree-ssa-copyrename.c (copy_rename_partition_coalesce):
Implement them.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/ivopts-2.C: Adjust for coalescing.
* gcc.dg/tree-ssa/forwprop-11.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-1.c: Likewise.

From-SVN: r188526

gcc/ChangeLog
gcc/common.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C
gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c
gcc/tree-ssa-copyrename.c

index 684361f11770dc319c3c44a132d52dd410415ab5..6969253b2578f5c755c8499c075ebfa7478f1b68 100644 (file)
@@ -1,3 +1,11 @@
+2012-06-13  Alexandre Oliva  <aoliva@redhat.com>
+
+       * common.opt (ftree-coalesce-inlined-vars): New.
+       (ftree-coalesce-vars): New.
+       * doc/invoke.texi: Document them.
+       * tree-ssa-copyrename.c (copy_rename_partition_coalesce):
+       Implement them.
+
 2012-06-13  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * read-rtl.c (mapping): Remove index field.  Add current_value field.
index 02c7cd3ee7a0ede002ee24ca8a9b068bfb18420c..5b1b4d8eea3f7c7faf930d5c43a5c788de7c4af9 100644 (file)
@@ -1944,6 +1944,14 @@ ftree-ch
 Common Report Var(flag_tree_ch) Optimization
 Enable loop header copying on trees
 
+ftree-coalesce-inlined-vars
+Common Report Var(flag_ssa_coalesce_vars,1) Init(2) RejectNegative Optimization
+Enable coalescing of copy-related user variables that are inlined
+
+ftree-coalesce-vars
+Common Report Var(flag_ssa_coalesce_vars,2) Optimization
+Enable coalescing of all copy-related user variables
+
 ftree-copyrename
 Common Report Var(flag_tree_copyrename) Optimization
 Replace SSA temporaries with better names in copies
index 2bb870a5edd169d4c0c69922eebc15831cb86f2b..621ef29f8deccab928ed5b307de82d8904c5e1be 100644 (file)
@@ -405,7 +405,8 @@ Objective-C and Objective-C++ Dialects}.
 -fsplit-ivs-in-unroller -fsplit-wide-types -fstack-protector @gol
 -fstack-protector-all -fstrict-aliasing -fstrict-overflow @gol
 -fthread-jumps -ftracer -ftree-bit-ccp @gol
--ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copy-prop @gol
+-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
+-ftree-coalesce-inline-vars -ftree-coalesce-vars -ftree-copy-prop @gol
 -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse @gol
 -ftree-forwprop -ftree-fre -ftree-loop-if-convert @gol
 -ftree-loop-if-convert-stores -ftree-loop-im @gol
@@ -7490,6 +7491,24 @@ temporaries to other variables at copy locations, usually resulting in
 variable names which more closely resemble the original variables.  This flag
 is enabled by default at @option{-O} and higher.
 
+@item -ftree-coalesce-inlined-vars
+Tell the copyrename pass (see @option{-ftree-copyrename}) to attempt to
+combine small user-defined variables too, but only if they were inlined
+from other functions.  It is a more limited form of
+@option{-ftree-coalesce-vars}.  This may harm debug information of such
+inlined variables, but it will keep variables of the inlined-into
+function apart from each other, such that they are more likely to
+contain the expected values in a debugging session.  This was the
+default in GCC versions older than 4.7.
+
+@item -ftree-coalesce-vars
+Tell the copyrename pass (see @option{-ftree-copyrename}) to attempt to
+combine small user-defined variables too, instead of just compiler
+temporaries.  This may severely limit the ability to debug an optimized
+program compiled with @option{-fno-var-tracking-assignments}.  In the
+negated form, this flag prevents SSA coalescing of user variables,
+including inlined ones.  This option is enabled by default.
+
 @item -ftree-ter
 @opindex ftree-ter
 Perform temporary expression replacement during the SSA->normal phase.  Single
index a8384ffc4ab13167e5ae850ab33156f40945e562..8e6000d1b2658dedb2cb875fb86da34348fbe0a1 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-13  Alexandre Oliva  <aoliva@redhat.com>
+
+       * g++.dg/tree-ssa/ivopts-2.C: Adjust for coalescing.
+       * gcc.dg/tree-ssa/forwprop-11.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-fre-1.c: Likewise.
+
 2012-06-13  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/53643
index 908299d98e89d33a55e76d91f376114e0b7c5bb7..83b5728ef1a4bcaf935d1411d7aaf118ac0881e8 100644 (file)
@@ -7,5 +7,5 @@ void test (int *b, int *e, int stride)
       *p = 1;
   }
 
-/* { dg-final { scan-tree-dump-times "PHI <p" 1 "ivopts"} } */
+/* { dg-final { scan-tree-dump-times "PHI <\[pb\]" 1 "ivopts"} } */
 /* { dg-final { cleanup-tree-dump "ivopts" } } */
index 24c9d16d9dbee567a4cb8ead4066869f7315c37d..08d0864af55d200d24be5e6832b0d371d03eb339 100644 (file)
@@ -16,5 +16,5 @@ int g(int *p, int n)
   return q[-1];
 }
 
-/* { dg-final { scan-tree-dump-times "= MEM\\\[\\\(int \\\*\\\)a_.. \\\+ 4B\\\];" 2 "forwprop1" } } */
+/* { dg-final { scan-tree-dump-times "= MEM\\\[\\\(int \\\*\\\)\[ap\]_.. \\\+ 4B\\\];" 2 "forwprop1" } } */
 /* { dg-final { cleanup-tree-dump "forwprop1" } } */
index 2c859d5e850969497e9fc657ebce167898f759f4..058d337378532b5e82b992adb29bb823ed4e7189 100644 (file)
@@ -11,5 +11,5 @@ int f(int *a)
   return *c + t;
 }
 
-/* { dg-final { scan-tree-dump "Replaced \\\*c_\[^\n\].*with t_" "fre1" } } */
+/* { dg-final { scan-tree-dump "Replaced \\\*\[ac\]_\[^\n\].*with t_" "fre1" } } */
 /* { dg-final { cleanup-tree-dump "fre1" } } */
index 3e01b6efab9bbd2d68f392f3415a5edc9a258d99..6ee8380a9a16dc4befe45b09622acff42bb3bc4f 100644 (file)
@@ -194,20 +194,21 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
   ign1 = TREE_CODE (root1) == VAR_DECL && DECL_IGNORED_P (root1);
   ign2 = TREE_CODE (root2) == VAR_DECL && DECL_IGNORED_P (root2);
 
-  /* Never attempt to coalesce 2 user variables unless one is an inline
-     variable.  */
+  /* Refrain from coalescing user variables, if requested.  */
   if (!ign1 && !ign2)
     {
-      if (DECL_FROM_INLINE (root2))
-        ign2 = true;
-      else if (DECL_FROM_INLINE (root1))
+      if (flag_ssa_coalesce_vars && DECL_FROM_INLINE (root2))
+       ign2 = true;
+      else if (flag_ssa_coalesce_vars && DECL_FROM_INLINE (root1))
        ign1 = true;
-      else
+      else if (flag_ssa_coalesce_vars != 2)
        {
          if (debug)
            fprintf (debug, " : 2 different USER vars. No coalesce.\n");
          return false;
        }
+      else
+       ign2 = true;
     }
 
   /* If both values have default defs, we can't coalesce.  If only one has a