From patchwork Tue Jul 2 14:32:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sawdey X-Patchwork-Id: 1126272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-504190-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XY8cV2oR"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dRYQ0w4xz9sLt for ; Wed, 3 Jul 2019 00:33:12 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=eTkBQ qE97UrFdFMyi5DReU4oirBAwLJFs3AJd9tLdZTJkrVi8tQfy83uUnOmEZatcDTGM MLpiYgadKNr8V+CjhohT6Gx2R7scp9UW2rv7g0+EMxYkn8ubFGiefDAe1engtH6W u6wm2qiaMbuRmK0JN3Km2hZdDk9wW04BOWNVGc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=4ENzagywyi6 IEnRELPDSpmfaX3A=; b=XY8cV2oRZ4VH7OHf+6hEow3eu2B/aA+Nuh3yfHDaduj wqaO++wRVFHknY8pxb2vEM96c7mCsm4wDBXPn2mqEmOEJH7bG//skreLi1XUHw5M WhondaKau5ySmhLj4ULStN7BcgLFPPrWgopA3oK4BQMcuDk8d9C5NOHJeClubrDc = Received: (qmail 18916 invoked by alias); 2 Jul 2019 14:33:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 18906 invoked by uid 89); 2 Jul 2019 14:33:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.8 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=impose, cpymem_optab, fourth, movmem_optab X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Jul 2019 14:33:03 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x62EWaj7098063 for ; Tue, 2 Jul 2019 10:33:00 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tg6j6q4dg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 02 Jul 2019 10:33:00 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Jul 2019 15:32:59 +0100 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 2 Jul 2019 15:32:56 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x62EWtvn58196400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Jul 2019 14:32:55 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78BB6BE04F; Tue, 2 Jul 2019 14:32:55 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03026BE051; Tue, 2 Jul 2019 14:32:54 +0000 (GMT) Received: from ragesh4.local (unknown [9.163.52.36]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 2 Jul 2019 14:32:54 +0000 (GMT) To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool , Bill Schmidt , David Edelsohn , rguenther@suse.de, Jakub Jelinek , Jeff Law From: Aaron Sawdey Subject: [PATCH] Add movmem optab entry back in for overlapping moves Date: Tue, 2 Jul 2019 09:32:54 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 x-cbid: 19070214-0036-0000-0000-00000AD2D507 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011365; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01226402; UDB=6.00645646; IPR=6.01007623; MB=3.00027555; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-02 14:32:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19070214-0037-0000-0000-00004C7126FB Message-Id: X-IsSubscribed: yes This is the second piece for allowing inline expansion of memmove. Now that the old movmem patterns have all been renamed to cpymem, the movmem optab can be added back. Next piece will be: add support for __builtin_memmove() to use the movmem optab and associated patterns. This patch passes bootstrap/regtest on ppc64le and x86_64. Ok for trunk? 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. Index: gcc/doc/md.texi =================================================================== --- gcc/doc/md.texi (revision 272762) +++ gcc/doc/md.texi (working copy) @@ -6237,6 +6237,42 @@ 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 Index: gcc/optabs.def =================================================================== --- gcc/optabs.def (revision 272762) +++ gcc/optabs.def (working copy) @@ -257,6 +257,7 @@ 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")