Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4209393rwl; Mon, 10 Apr 2023 07:44:08 -0700 (PDT) X-Google-Smtp-Source: AKy350a73A+a7JTsxxnjHPqjL2fsI+AptcyTY3oQXuV4RVI6SPDtFa0RkkcPylo09d8mYkHiDM7r X-Received: by 2002:a17:907:d08e:b0:94a:4ce3:803d with SMTP id vc14-20020a170907d08e00b0094a4ce3803dmr6031778ejc.15.1681137848443; Mon, 10 Apr 2023 07:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681137848; cv=none; d=google.com; s=arc-20160816; b=xVfM++x1MvujMhlQB1Pd8hzedVXpfXZIzcrVG/sWYLQ5bkjPAbCgbnhRu/9lQPUQlN VaDS6xdIX9NF2I/V06E/pRIDGGJTH1j/nKzOb87zL69qLmX6hmLdWSM9M5pbW8xfGP26 R4fbh6JkGtoa0nKaVIxpDorSoYAxyITPFplHNfrQoNM3ZdApaiBsQHTKY8KRYbcFpUAw 5JqlzYOEagokYsAdCyjV+Ey7k4V7t1RP5JvrLcG2M18FTM4Ew3j2fF6ZgAzEWMM4ep1U ePVBPhebS2uWdJHGvUbGwvsono72fZgjcm04VTFU2TmjGUlZe+UvpSBbVu6gQIKKGDnt Q0yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=pJ5huZALXOGNHYxFvmjqdHM2n/QsyclgPnpsgrZlgts=; b=aIR2TZgxOCDe5NMhAhWnsi0ICEnHGVE4sHfk5Z5qLEPR/4BODkg7nYHOjpHS6KZIob OR0sVkdsAF9NVNmafJSQjQwlu8rH8nrSYSUEMDBoO8XKOg1HappfLNE2M420RkShuIdQ TZYICsthtj7LbKs76kwAJkPPhA7C3RzOFK9OKE+8mIq3BXbcuqxIdrvdyjVbab+dghH7 uBj4G0Zmo6fkANknNKY3QjvIfsgLazMEQl2pAxiJQ6MUK8ssze8iZ97XrFSGUgX42DoB RGbdXX2dhrzBYvZSWwPw7RQdd/YDDpMK3BSYrjQGQbvYqhaU7OMgAwDhedxX893PXdQp AVug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=dYhgOa37; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp7-20020a1709073e0700b00946e67fcf7fsi11239225ejc.124.2023.04.10.07.43.43; Mon, 10 Apr 2023 07:44:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=dYhgOa37; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229875AbjDJOgy (ORCPT + 99 others); Mon, 10 Apr 2023 10:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbjDJOgu (ORCPT ); Mon, 10 Apr 2023 10:36:50 -0400 Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6CD6EBA for ; Mon, 10 Apr 2023 07:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1681137405; bh=7Ou+Ia0snPVjCODygIjKbRhpJiBd7TgzfRo2LeXCpN4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=dYhgOa377ymqvloqAJ/dBdaDbatV1kYqiNLnYBpeTr77mS01SVWX1PFiFeqH4Ic1J 6qbj3mTsyQ65sA+PuPFxWGo0mroRTEApyDTGO0dMYXELPHMXGJ8ysoMV+OWMy40oAd XOmHzjkNFu6GCtM84K4/Tk94SA09kTgCfGnR2tRo= Received: from [IPv6:240e:358:1117:7c00:dc73:854d:832e:5] (unknown [IPv6:240e:358:1117:7c00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 7DF4165A30; Mon, 10 Apr 2023 10:36:40 -0400 (EDT) Message-ID: <8aeb6d8dc4cbe8c992b69d75d8953d59b71a2c38.camel@xry111.site> Subject: Re: [PATCH] LoongArch: Improve memory ops From: Xi Ruoyao To: Rui Wang Cc: Huacai Chen , WANG Xuerui , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Date: Mon, 10 Apr 2023 22:36:26 +0800 In-Reply-To: References: <20230410115734.93365-1-wangrui@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2023-04-10 at 22:22 +0800, Rui Wang wrote: > On Mon, Apr 10, 2023 at 8:54=E2=80=AFPM Xi Ruoyao wr= ote: > > Regarding these functions: we have -ffreestanding which is > > preventing > > the compiler from optimizing for e.g. "memcpy(a, b, 8);" into a > > simple > > ld.d/st.d pair.=C2=A0 A explicit compiler built-in usage like > >=20 > > =C2=A0 #define memcpy(a, b, c) __builtin_memcpy(a, b, c) > >=20 > > would allow the compiler to do such kind of optimization.=C2=A0=C2=A0 W= ill > > this > > improve the performance? >=20 > That's a good question. IIUC, the current compiler generates > inefficient code for constant-length memcpy, which may sacrifice > performance for compatibility, as not all hardware supports unaligned > memory access. We need a runtime CPU feature dispatch mechanism > similar to alternatives to improve the compiler. This is indeed a > problem that needs to be addressed. Hmm, yep, GCC does not take the advantage of -mstrict-align expanding memcpy etc. I'll add it into my TODO list for GCC 14. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University