params.def (PARAM_SRA_MAX_STRUCTURE_SIZE): New.
authorBen Elliston <bje@au.ibm.com>
Wed, 27 Oct 2004 21:02:16 +0000 (21:02 +0000)
committerBen Elliston <bje@gcc.gnu.org>
Wed, 27 Oct 2004 21:02:16 +0000 (07:02 +1000)
* params.def (PARAM_SRA_MAX_STRUCTURE_SIZE): New.
(PARAM_SRA_FIELD_STRUCTURE_RATIO): Likewise.
* params.h (SRA_MAX_STRUCTURE_SIZE): New.
(SRA_FIELD_STRUCTURE_RATIO): Likewise.
* tree-sra.c: Include "params.h".
(decide_block_copy): Use new parameters.
* doc/invoke.texi (Optimize Options): Document new SRA pass
parameters sra-max-structure-size and sra-field-structure-ratio.

[testsuite]
* gcc.dg/tree-ssa/sra-1.c: Pass --param sra-max-structure-size.

From-SVN: r89711

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/params.def
gcc/params.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/sra-1.c
gcc/tree-sra.c

index 898e2e9da93efc16382c5b3420a09cacd6ebe615..8d197339b70c510cd145ad2961affa31ff231608 100644 (file)
@@ -1,3 +1,14 @@
+2004-10-28  Ben Elliston  <bje@au.ibm.com>
+
+       * params.def (PARAM_SRA_MAX_STRUCTURE_SIZE): New.
+       (PARAM_SRA_FIELD_STRUCTURE_RATIO): Likewise.
+       * params.h (SRA_MAX_STRUCTURE_SIZE): New.
+       (SRA_FIELD_STRUCTURE_RATIO): Likewise.
+       * tree-sra.c: Include "params.h".
+       (decide_block_copy): Use new parameters.
+       * doc/invoke.texi (Optimize Options): Document new SRA pass
+       parameters sra-max-structure-size and sra-field-structure-ratio.
+
 2004-10-27  Nicolas Pitre <nico@cam.org>
 
        * config/arm/ieee754-df.S (floatdidf): Fix regression with big values.
index 990b83c64ef8c8a72da27bb4bc9d9b2ae1477226..ceeae2279aad20ec9a9d80b1cad9099d3f60f245 100644 (file)
@@ -5313,6 +5313,19 @@ In each case, the @var{value} is an integer.  The allowable choices for
 @var{name} are given in the following table:
 
 @table @gcctabopt
+@item sra-max-structure-size
+The maximum structure size, in bytes, at which the scalar replacement
+of aggregates (SRA) optimization will perform block copies.  The
+default value, 0, implies that GCC will select the most appropriate
+size itself.
+
+@item sra-field-structure-ratio
+The treshold ratio (as a percentage) between instantiated fields and
+the complete structure size.  We say that if the ratio of the number
+of bytes in instantiated fields to the number of bytes in the complete
+structure exceeds this parameter, then block copies are not used.  The
+default is 75.
+
 @item max-crossjump-edges
 The maximum number of incoming edges to consider for crossjumping.
 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
index 79c55bcd2c1bf27b2a8cddba74ffdeb97ff62d8f..5bde4a16c77d24f44cf9b8a38cfe4d9fbd746c85 100644 (file)
@@ -35,6 +35,25 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
    Be sure to add an entry to invoke.texi summarizing the parameter.  */
 
+/* The maximum structure size at which the scalar replacement of
+   aggregates (SRA) pass will perform block copies.  The default
+   value, 0, implies that GCC will select the most appropriate size
+   itself.  */
+DEFPARAM (PARAM_SRA_MAX_STRUCTURE_SIZE,
+         "sra-max-structure-size",
+         "The maximum structure size (in bytes) at which GCC will do block copies.",
+         0)
+
+/* The ratio between instantiated fields and the complete structure
+   size.  We say that if the ratio of the number of bytes in
+   instantiated fields to the number of bytes in the complete
+   structure exceeds this parameter, then block copies are not used.
+   The default is 75%.  */
+DEFPARAM (PARAM_SRA_FIELD_STRUCTURE_RATIO,
+         "sra-field-structure-ratio",
+         "The threshold ratio between instantiated fields and the total structure size.",
+         75)
+
 /* The single function inlining limit. This is the maximum size
    of a function counted in internal gcc instructions (not in
    real machine instructions) that is eligible for inlining
index b17625ea86f40c387e9b0b4823eb09a6895e59b7..0ebb9729be7ca0c40f899d1a905be1fb9c324e3e 100644 (file)
@@ -82,6 +82,10 @@ typedef enum compiler_param
   (compiler_params[(int) ENUM].value)
 
 /* Macros for the various parameters.  */
+#define SRA_MAX_STRUCTURE_SIZE \
+  PARAM_VALUE (PARAM_SRA_MAX_STRUCTURE_SIZE)
+#define SRA_FIELD_STRUCTURE_RATIO \
+  PARAM_VALUE (PARAM_SRA_FIELD_STRUCTURE_RATIO)
 #define MAX_INLINE_INSNS_SINGLE \
   PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SINGLE)
 #define MAX_INLINE_INSNS \
index 1329715a1c6dffc5d8c6236cecca167247c300cc..8d984cc8c3438b3367af1239ed5a487c25b58335 100644 (file)
@@ -1,3 +1,7 @@
+2004-10-28  Ben Elliston  <bje@au.ibm.com>
+
+       * gcc.dg/tree-ssa/sra-1.c: Pass --param sra-max-structure-size.
+
 2004-10-27  Nathan Sidwell  <nathan@codesourcery.com>
 
        * gcc.dg/cpp/direct2.c: Cope with different bison 'parse' or
index 652f402dc834751aed9bc4f8fe7746ce28f07e79..c018fbb9dec0cf2b99bc34ef55b2f75ada92756f 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */ 
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized --param sra-max-structure-size=32" } */
 
 /* Tests for SRA. */
 
index 7519c3cfa676f56967708b87f8a0572f959fd2bd..9fd40f9822cc0acae648e19e152d145a81cc815b 100644 (file)
@@ -48,6 +48,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "target.h"
 /* expr.h is needed for MOVE_RATIO.  */
 #include "expr.h"
+#include "params.h"
 
 
 /* This object of this pass is to replace a non-addressable aggregate with a
@@ -1292,6 +1293,14 @@ decide_block_copy (struct sra_elt *elt)
        {
          unsigned HOST_WIDE_INT full_size, inst_size = 0;
          unsigned int inst_count;
+         unsigned int max_size;
+
+         /* If the sra-max-structure-size parameter is 0, then the
+            user has not overridden the parameter and we can choose a
+            sensible default.  */
+         max_size = SRA_MAX_STRUCTURE_SIZE
+           ? SRA_MAX_STRUCTURE_SIZE
+           : MOVE_RATIO * UNITS_PER_WORD;
 
          full_size = tree_low_cst (size_tree, 1);
 
@@ -1302,14 +1311,14 @@ decide_block_copy (struct sra_elt *elt)
 
          /* If the structure is small, and we've made copies, go ahead
             and instantiate, hoping that the copies will go away.  */
-         if (full_size <= (unsigned) MOVE_RATIO * UNITS_PER_WORD
+         if (full_size <= max_size
              && elt->n_copies > elt->n_uses)
            use_block_copy = false;
          else
            {
              inst_count = sum_instantiated_sizes (elt, &inst_size);
 
-             if (inst_size * 4 >= full_size * 3)
+             if (inst_size * 100 >= full_size * SRA_FIELD_STRUCTURE_RATIO)
                use_block_copy = false;
            }