From patchwork Thu Sep 7 16:14:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 137651 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:d1d:b0:13f:353d:d1ed with SMTP id gp29csp82rwb; Thu, 7 Sep 2023 09:18:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYMoAt9UM3MmoX/E25MGWszbMgdHC3T4ECvgWIQ+OXh7r8j4321PRcDUvpg5dl2GC1Jbe0 X-Received: by 2002:a05:6402:794:b0:523:cfa4:5c3d with SMTP id d20-20020a056402079400b00523cfa45c3dmr5299526edy.13.1694103513756; Thu, 07 Sep 2023 09:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694103513; cv=none; d=google.com; s=arc-20160816; b=lpImbDOwVdhw9L9EX+xrbB7iWC0xTve9253MteZQbnkDx3CQmtz4hIm/F4OcHViPB1 +09UZpwONhEs54FHIdVXjicff3saMg2g0omJ99VaaeWzO51rwf1d+i26w+t801oiayLZ cwXw1DfWtR5iJ9EjOlwXcqTYoC+YhieRDsKt5+jlUg8LcrJeRlkbSxxDDZY1M5Yj72Ss tPe/wy9/WAqTHK+Pj0o0mPGDvNbALDHWG2nKAZefIhtP5ZfsvyHa1N4GMBg0j+NcxyyB ytW/J8ti8y9L7op8WzEf8vRY2G1a+2oJcoyEbGjqjoiXq0x2lSNg7SaA92j7IU4xC3Ae i8cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=dV5r9TL5TEU0KLzNZtAIObXp0awzEaU9I5xG9Vq+278=; fh=vmcU0DqAlp2ffUs2X9j+erxKIBIRuu9vEl0GfmJ3sC0=; b=qQXOX3WLgWNd6LpVeg8UauCkgnz4jIOSCnFJuK3lTOeUY+hhqi/4RonNNTf7zipGwE ruvjHOC/kq4oW4JUGWkelPhpQagZK4n+MZ1R1QXzoDR/LpJvNSOUExYlSqaXzvWI7Hmc L+SNtkxKHURdXrhbzxQHUXYJ06xAJmoRArDhzDGmgEH1oil2UmQFR6lC3LwB23VHV5ti 2oiX//1Mk7NYR1EhdAXBN5KUM7HTOJwnhyjbtolZgGrFXNoJEfcilHBqJYzlQ2O0aRDT bo9hXFQdbSgycsyu7EYickP2JcQ9lINnx6PiHq6+e/3rGoblzMHuZfn7UtW7eKHGnRwn lbug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oXey7u+p; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d14-20020aa7ce0e000000b0052889bc60e8si11113017edv.97.2023.09.07.09.18.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 09:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oXey7u+p; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00D693858410 for ; Thu, 7 Sep 2023 16:18:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00D693858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694103505; bh=dV5r9TL5TEU0KLzNZtAIObXp0awzEaU9I5xG9Vq+278=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=oXey7u+p4OGg09bqheSy5uVy6+7tDPwgih105jNhfCHvZA7Og/Nxb3qCiGiYUyEsT /HTAXkN3iiam9aaKEVfdRTiBKOulT59yPpuhYldsExOYG929UfM+DJXskR9MoR9GGN LrKQKOhESUd54Xql2WdtC5G5p80/q7N+PVJ4kH24= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id C4C583858D1E for ; Thu, 7 Sep 2023 16:17:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4C583858D1E Received: from stargazer.. (unknown [IPv6:240e:358:1175:f400:dc73:854d:832e:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 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 182CD659AC; Thu, 7 Sep 2023 12:17:33 -0400 (EDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] LoongArch: Use LSX and LASX for block move Date: Fri, 8 Sep 2023 00:14:08 +0800 Message-ID: <20230907161407.27338-2-xry111@xry111.site> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Gcc-patches From: Xi Ruoyao Reply-To: Xi Ruoyao Cc: xuchenghua@loongson.cn, Chenghui Pan , chenglulu , i@xen0n.name Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776396286120602860 X-GMAIL-MSGID: 1776396286120602860 gcc/ChangeLog: * config/loongarch/loongarch.h (LARCH_MAX_MOVE_PER_INSN): Define to the maximum amount of bytes able to be loaded or stored with one machine instruction. * config/loongarch/loongarch.cc (loongarch_mode_for_move_size): New static function. (loongarch_block_move_straight): Call loongarch_mode_for_move_size for machine_mode to be moved. (loongarch_expand_block_move): Use LARCH_MAX_MOVE_PER_INSN instead of UNITS_PER_WORD. --- Bootstrapped and regtested on loongarch64-linux-gnu, with PR110939 patch applied, the "lib_build_self_spec = %<..." line in t-linux commented out (because it's silently making -mlasx in BOOT_CFLAGS ineffective, Yujie is working on a proper fix), and BOOT_CFLAGS="-O3 -mlasx". Ok for trunk? gcc/config/loongarch/loongarch.cc | 22 ++++++++++++++++++---- gcc/config/loongarch/loongarch.h | 3 +++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 6698414281e..509ef2b97f1 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -5191,6 +5191,20 @@ loongarch_function_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED, return true; } +static machine_mode +loongarch_mode_for_move_size (HOST_WIDE_INT size) +{ + switch (size) + { + case 32: + return V32QImode; + case 16: + return V16QImode; + } + + return int_mode_for_size (size * BITS_PER_UNIT, 0).require (); +} + /* Emit straight-line code to move LENGTH bytes from SRC to DEST. Assume that the areas do not overlap. */ @@ -5220,7 +5234,7 @@ loongarch_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length, for (delta_cur = delta, i = 0, offs = 0; offs < length; delta_cur /= 2) { - mode = int_mode_for_size (delta_cur * BITS_PER_UNIT, 0).require (); + mode = loongarch_mode_for_move_size (delta_cur); for (; offs + delta_cur <= length; offs += delta_cur, i++) { @@ -5231,7 +5245,7 @@ loongarch_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length, for (delta_cur = delta, i = 0, offs = 0; offs < length; delta_cur /= 2) { - mode = int_mode_for_size (delta_cur * BITS_PER_UNIT, 0).require (); + mode = loongarch_mode_for_move_size (delta_cur); for (; offs + delta_cur <= length; offs += delta_cur, i++) loongarch_emit_move (adjust_address (dest, mode, offs), regs[i]); @@ -5326,8 +5340,8 @@ loongarch_expand_block_move (rtx dest, rtx src, rtx r_length, rtx r_align) HOST_WIDE_INT align = INTVAL (r_align); - if (!TARGET_STRICT_ALIGN || align > UNITS_PER_WORD) - align = UNITS_PER_WORD; + if (!TARGET_STRICT_ALIGN || align > LARCH_MAX_MOVE_PER_INSN) + align = LARCH_MAX_MOVE_PER_INSN; if (length <= align * LARCH_MAX_MOVE_OPS_STRAIGHT) { diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index 3fc9dc43ab1..7e391205583 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -1181,6 +1181,9 @@ typedef struct { least twice. */ #define LARCH_MAX_MOVE_OPS_STRAIGHT (LARCH_MAX_MOVE_OPS_PER_LOOP_ITER * 2) +#define LARCH_MAX_MOVE_PER_INSN \ + (ISA_HAS_LASX ? 32 : (ISA_HAS_LSX ? 16 : UNITS_PER_WORD)) + /* The base cost of a memcpy call, for MOVE_RATIO and friends. These values were determined experimentally by benchmarking with CSiBE. */