expr.c [...]: New macro defining the maximum number of move instructions to use when...
authorRoger Sayle <roger@eyesopen.com>
Sat, 13 Jul 2002 00:13:15 +0000 (00:13 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sat, 13 Jul 2002 00:13:15 +0000 (00:13 +0000)
* expr.c [CLEAR_RATIO]: New macro defining the maximum number
of move instructions to use when clearing memory, c.f. MOVE_RATIO.
[CLEAR_BY_PIECES]: New macro, using CLEAR_RATIO, to determine
whether clear_by_pieces should be used to clear storage.
(clear_storage): Use CLEAR_BY_PIECES instead of MOVE_BY_PIECES.

* doc/tm.texi: Document these two new target macros.

From-SVN: r55429

gcc/ChangeLog
gcc/doc/tm.texi
gcc/expr.c

index 26c70074ea51a5527d44860e1aa8c5f3179a769a..8117485ac6fbd9dbe4b19b08fc9094f99e699876 100644 (file)
@@ -1,3 +1,13 @@
+2002-07-12  Roger Sayle  <roger@eyesopen.com>
+
+       * expr.c [CLEAR_RATIO]: New macro defining the maximum number
+       of move instructions to use when clearing memory, c.f. MOVE_RATIO.
+       [CLEAR_BY_PIECES]: New macro, using CLEAR_RATIO, to determine
+       whether clear_by_pieces should be used to clear storage.
+       (clear_storage): Use CLEAR_BY_PIECES instead of MOVE_BY_PIECES.
+
+       * doc/tm.texi: Document these two new target macros.
+
 2002-07-12  Stephane Carrez  <stcarrez@nerim.fr>
 
        * config/m68hc11/m68hc11.md ("zero_extendsidi2"): Use D_REG only for
index daebec717a6f006751f04763b077dd7c175648f5..813482edc5296a16dfc5c28d7a057aa8f6f54a73 100644 (file)
@@ -5325,6 +5325,22 @@ than @code{MOVE_RATIO}.
 A C expression used by @code{move_by_pieces} to determine the largest unit
 a load or store used to copy memory is.  Defaults to @code{MOVE_MAX}.
 
+@findex CLEAR_RATIO
+@item CLEAR_RATIO
+The threshold of number of scalar move insns, @emph{below} which a sequence
+of insns should be generated to clear memory instead of a string clear insn
+or a library call.  Increasing the value will always make code faster, but
+eventually incurs high cost in increased code size.
+
+If you don't define this, a reasonable default is used.
+
+@findex CLEAR_BY_PIECES_P
+@item CLEAR_BY_PIECES_P (@var{size}, @var{alignment})
+A C expression used to determine whether @code{clear_by_pieces} will be used
+to clear a chunk of memory, or whether some other block clear mechanism
+will be used.  Defaults to 1 if @code{move_by_pieces_ninsns} returns less
+than @code{CLEAR_RATIO}.
+
 @findex USE_LOAD_POST_INCREMENT
 @item USE_LOAD_POST_INCREMENT (@var{mode})
 A C expression used to determine whether a load postincrement is a good
index 779bf8797559effda71d78f27a8666b630b83f9c..870a4c527bf2ff9f15d1fe33a1b681c7c3aa6108 100644 (file)
@@ -192,6 +192,25 @@ static bool float_extend_from_mem[NUM_MACHINE_MODES][NUM_MACHINE_MODES];
   (move_by_pieces_ninsns (SIZE, ALIGN) < (unsigned int) MOVE_RATIO)
 #endif
 
+/* If a clear memory operation would take CLEAR_RATIO or more simple
+   move-instruction sequences, we will do a clrstr or libcall instead.  */
+
+#ifndef CLEAR_RATIO
+#if defined (HAVE_clrstrqi) || defined (HAVE_clrstrhi) || defined (HAVE_clrstrsi) || defined (HAVE_clrstrdi) || defined (HAVE_clrstrti)
+#define CLEAR_RATIO 2
+#else
+/* If we are optimizing for space, cut down the default clear ratio.  */
+#define CLEAR_RATIO (optimize_size ? 3 : 15)
+#endif
+#endif
+
+/* This macro is used to determine whether clear_by_pieces should be
+   called to clear storage.  */
+#ifndef CLEAR_BY_PIECES_P
+#define CLEAR_BY_PIECES_P(SIZE, ALIGN) \
+  (move_by_pieces_ninsns (SIZE, ALIGN) < (unsigned int) CLEAR_RATIO)
+#endif
+
 /* This array records the insn_code of insns to perform block moves.  */
 enum insn_code movstr_optab[NUM_MACHINE_MODES];
 
@@ -2633,7 +2652,7 @@ clear_storage (object, size)
       size = protect_from_queue (size, 0);
 
       if (GET_CODE (size) == CONST_INT
-         && MOVE_BY_PIECES_P (INTVAL (size), align))
+         && CLEAR_BY_PIECES_P (INTVAL (size), align))
        clear_by_pieces (object, INTVAL (size), align);
       else
        {