From: Aaron Sawdey Date: Tue, 2 Jul 2019 18:51:23 +0000 (-0500) Subject: optabs.def (movmem_optab): Add movmem back for memmove(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=02e3025e174e6e93ab2675f49baf4df617e59c68;p=gcc.git optabs.def (movmem_optab): Add movmem back for memmove(). 2019-07-02 Aaron Sawdey * optabs.def (movmem_optab): Add movmem back for memmove(). * doc/md.texi: Add description of movmem pattern for overlapping move. From-SVN: r272946 --- diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 3f9d545a1a5..b1fcc38d76b 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -6237,6 +6237,42 @@ to the possibility that the source and destination strings might overlap. These patterns are used to do inline expansion of @code{__builtin_memcpy}. +@cindex @code{movmem@var{m}} instruction pattern +@item @samp{movmem@var{m}} +Block move instruction. The destination and source blocks of memory +are the first two operands, and both are @code{mem:BLK}s with an +address in mode @code{Pmode}. + +The number of bytes to copy is the third operand, in mode @var{m}. +Usually, you specify @code{Pmode} for @var{m}. However, if you can +generate better code knowing the range of valid lengths is smaller than +those representable in a full Pmode pointer, you should provide +a pattern with a +mode corresponding to the range of values you can handle efficiently +(e.g., @code{QImode} for values in the range 0--127; note we avoid numbers +that appear negative) and also a pattern with @code{Pmode}. + +The fourth operand is the known shared alignment of the source and +destination, in the form of a @code{const_int} rtx. Thus, if the +compiler knows that both source and destination are word-aligned, +it may provide the value 4 for this operand. + +Optional operands 5 and 6 specify expected alignment and size of block +respectively. The expected alignment differs from alignment in operand 4 +in a way that the blocks are not required to be aligned according to it in +all cases. This expected alignment is also in bytes, just like operand 4. +Expected size, when unknown, is set to @code{(const_int -1)}. + +Descriptions of multiple @code{movmem@var{m}} patterns can only be +beneficial if the patterns for smaller modes have fewer restrictions +on their first, second and fourth operands. Note that the mode @var{m} +in @code{movmem@var{m}} does not impose any restriction on the mode of +individually copied data units in the block. + +The @code{movmem@var{m}} patterns must correctly handle the case where +the source and destination strings overlap. These patterns are used to +do inline expansion of @code{__builtin_memmove}. + @cindex @code{movstr} instruction pattern @item @samp{movstr} String copy instruction, with @code{stpcpy} semantics. Operand 0 is diff --git a/gcc/optabs.def b/gcc/optabs.def index 03a08da575a..4ffd0f35a40 100644 --- a/gcc/optabs.def +++ b/gcc/optabs.def @@ -257,6 +257,7 @@ OPTAB_D (cmpmem_optab, "cmpmem$a") OPTAB_D (cmpstr_optab, "cmpstr$a") OPTAB_D (cmpstrn_optab, "cmpstrn$a") OPTAB_D (cpymem_optab, "cpymem$a") +OPTAB_D (movmem_optab, "movmem$a") OPTAB_D (setmem_optab, "setmem$a") OPTAB_D (strlen_optab, "strlen$a")