From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9957 invoked by alias); 15 May 2019 14:11:17 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 9949 invoked by uid 89); 15 May 2019 14:11:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 May 2019 14:11:16 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E5C130B6504; Wed, 15 May 2019 14:11:15 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5A1C1001E85; Wed, 15 May 2019 14:11:12 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x4FEBA53026496; Wed, 15 May 2019 16:11:10 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x4FEB6rL026495; Wed, 15 May 2019 16:11:06 +0200 Date: Wed, 15 May 2019 14:11:00 -0000 From: Jakub Jelinek To: Michael Matz Cc: Aaron Sawdey , Richard Biener , GCC Development , Joseph Myers , Jeff Law , Segher Boessenkool , David Edelsohn , Bill Schmidt Subject: Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy Message-ID: <20190515141106.GK19695@tucnak> Reply-To: Jakub Jelinek References: <21ca63aa-3838-e2ae-bf6e-39ec1b98dca4@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-IsSubscribed: yes X-SW-Source: 2019-05/txt/msg00114.txt.bz2 On Wed, May 15, 2019 at 02:02:32PM +0000, Michael Matz wrote: > > Yes this would be a nice thing to get to, a single move/copy underlying > > builtin, to which we communicate what the compiler's analysis tells us > > about whether the operands overlap and by how much. > > > > Next question would be how do we move from the existing movmem pattern > > (which Michael Matz tells us should be renamed cpymem anyway) to this > > new thing. Are you proposing that we still have both movmem and cpymem > > optab entries underneath to call the patterns but introduce this new > > memmove_with_hints() to be used by things called by > > expand_builtin_memmove() and expand_builtin_memcpy()? > > I'd say so. There are multiple levels at play: > a) exposal to user: probably a new __builtint_memmove, or a new combined > builtin with a hint param to differentiate (but we can't get rid of > __builtin_memcpy/mempcpy/strcpy, which all can go through the same > route in the middleend) > b) getting it through the gimple pipeline, probably just a new builtin > code, trivial > c) expanding the new builtin, with the help of next items > d) RTL block moves: they are defined as non-overlapping and I don't think > we should change this (essentially they're the reflection of struct > copies in C) > e) how any of the above (builtins and RTL block moves) are implemented: > currently non-overlapping only, using movmem pattern when possible; > ultimately all sitting in the emit_block_move_hints() routine. Just one thing to note, our "memcpy" expectation is that either there is no overlap, or there is 100% overlap (src == dest), both all the current movmem == future cpymem expanders and all the supported library implementations do support that, though the latter just de-facto, it isn't a written guarantee. Jakub