From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 102F53858018; Wed, 20 Jan 2021 02:41:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 102F53858018 Received: by mail-wr1-x42b.google.com with SMTP id w5so21596139wrm.11; Tue, 19 Jan 2021 18:41:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=SX0dByma0eHp4/hE+vl0licwQUH0sDUoJvS3kUvWlvc=; b=YEvHkePLnO+ZCohTPJD8gM8/siCfkP13ZH2iucpCG9mTdFRIU0ZvIPfRiciYWcZuBO l14ha1mrLQxSXCPlelJUuqaxBThzRAczbQYcrQriCJBQQsvGTxBJWOLqS8csiUr/5kpI XAdkHtS2FUnhQK/vw9Ip/A45wYyrvDy2DyX7wJH/HlRwzwfL8Ij8kpdgDRsFycLxoLZL 1GzJN6qPwkF0Kj7fGnReuhElE1fTzHViJv6hAtjE4qPsgLpOJx7LcxWhVPzh4CfYIISR K1YdstgV95VZ6Jjxh/+9V1zVnJUFYxHERJ1w4JSBgyuID3faIUf70ibGCQYnF9/ZAwcA dPUA== X-Gm-Message-State: AOAM530VwdeJzog5yV+D2mRJIKXsHpDmv3WddHOgwy8ji/kEz8F4OVh6 vaZ7J6MZSnmL9Ttn1JuLgSgkpyDP4hY= X-Google-Smtp-Source: ABdhPJxQqj/sEdGbaobl7fU/w2Z0NQR3EP53SOHRxTEKT2y6nofd/a3b9WbKLVhWa86IyQx4NP2Dnw== X-Received: by 2002:a5d:4987:: with SMTP id r7mr7115174wrq.352.1611110487342; Tue, 19 Jan 2021 18:41:27 -0800 (PST) Received: from [10.18.0.3] ([217.138.207.234]) by smtp.gmail.com with ESMTPSA id r16sm1036366wrx.36.2021.01.19.18.41.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Jan 2021 18:41:26 -0800 (PST) Subject: Re: Should GCC provide __builtin_memcpy_inline like clang does? To: "gcc@gcc.gnu.org" , "gcc-help@gcc.gnu.org" References: From: Gabriel Ravier Message-ID: <3c787a8e-8008-ca68-a960-04b5ec1ec88a@gmail.com> Date: Wed, 20 Jan 2021 03:41:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, NICE_REPLY_A, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jan 2021 02:41:30 -0000 On 1/19/21 12:33 PM, unlvsur unlvsur via Gcc wrote: > I think __builtin_memmove_inline, __builtin_memset_inline can also get > provided. > > That allows better performance for small size copies Manual tweaking like that seems a bit ridiculous except in very narrow situations, and just letting GCC assume there is an implementation of memset/memmove lets it do optimization based on copy size by default. I guess there could be some value to such an extension for portably doing such specific micro-optimizations manually, though. > and allowing memcpy to be usable without libc. You can just define it yourself, don't worry, GCC won't mind (as long as it has the correct semantics). Even for the narrow case of memmove, which could be mildly inconvenient to implement in less than 10 lines on a few systems that have non-trivial pointers (i.e. `source < destination` doesn't work as expected), you're on freestanding, so you should be able to make some kind of working implementation by using non-standard stuff for that specific purpose.