From patchwork Tue Jan 16 02:23:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiahao Xu X-Patchwork-Id: 188364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp8073dye; Mon, 15 Jan 2024 18:24:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmSFAnYgVLLbZnFAer1npnrh+kA2j3qBOI3Z/e5wCmWXvctvDavHiETYSWGID5fglYaX4i X-Received: by 2002:a05:620a:424e:b0:783:3747:6c2f with SMTP id w14-20020a05620a424e00b0078337476c2fmr7632925qko.6.1705371859380; Mon, 15 Jan 2024 18:24:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705371859; cv=pass; d=google.com; s=arc-20160816; b=GbqfKPqJnQ+yHjLE9VpT8cchPcdapiV146t2dD8ZXUCPSCRmkyJAacpg1eWnuTG8G7 EhnRTYUf9RiKum6LC0WD2d1a6zJj1CsYHfautRGP/lQuZkFOk51pPA62IkJQHDRk83Fj n32S7K0iMsNbVztvX2xTo49jxc59VBu4LwZWsmR2q7zGMRh7PWuUos5/mLAY3tnJVnYx ldsfLWYqvPu+eq0uQxMDDuV786gGwId41VvHNn8zVA5IxIizUIc2ZagNnLB88k1fCaXi AOmE1pqQhoktnop2KIEbt9HCcysF8hylaGBeO2Akmf5LV8cCUSUrSlA6nMr1oePXdDXX ZzHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=P9yV4D8hCGBYgnX5K718jJQphcZMJGWK8FMqvA8sZbI=; fh=w+xsGLuzpTj56E0bzPMCc39RWHkBXt2f2AGs+4pGimo=; b=kmbYkhtVXpbQNAHGDUxJ5kJLIfJ5nDpSAs5a1UhAui7Vy4A0SiUlPP4wahYaQEXFaA oDp/y5dqa3WWZpU5do/DPfea7mt6JY+pX1CcO7C+UwOHcQVQ9XLB7KAAWCIREnh8lBwb jNiBoMx2BcDouD/eG1V2LszLc/f6rSG9Mwj2NffowucShSK1/A6qDIFg9TWwSKRnBlu9 1nfivZg+NUXEBTbDDebkEkWAYLthISBc8yxS45bVxaAtDs7uMIERSA4NxyJOmvvHps0O 0hu/XQE/RBX1lKwA6K8FFlp3I1tePu5iaCvtOPuBS/oonAAOJV1xA/++rpjkZjGve1PJ tA+w== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p10-20020a05620a056a00b007833b44dd66si8997041qkp.345.2024.01.15.18.24.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 18:24:19 -0800 (PST) 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; arc=pass (i=1); 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18BC63858414 for ; Tue, 16 Jan 2024 02:24:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 209EB3858D32 for ; Tue, 16 Jan 2024 02:23:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 209EB3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 209EB3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705371816; cv=none; b=c2glxshb70Qwr/MoBI5TX6au0UBlgPttZSxuysNXT+LsfbIeVy4HwRRkwB0TLNDduH49wu8RsjXUs+bYG93C9edn7Ki/QcjQr+VA0vfccBxWTmjZxADq+cpycj7/NSt2tXY8podx342V88SMcJ/X/DZFBR8vuIi5dDwmJ1Ibj6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705371816; c=relaxed/simple; bh=xywjncHwtYhREAbVgmPhmxxeX4hw2/iyk3evPR0S7Xg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=RJtDNBiF4HXu14Sry1MK+p6Mz7btFzop5ron7w2CSROxHhJh8bHW2igF4RhM1GIX6c/LKZHeYEeapRHi09fMqu7hgCGK9Ia8lwHMflH9z9XqS8AukjhAcMWTct1rDYOpV0ftIMBgcl/gmpJyhOuekGL6eAFaNiKyo+d9qMYU3RM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.10.130.252]) by gateway (Coremail) with SMTP id _____8BxXeud6KVlkowAAA--.2505S3; Tue, 16 Jan 2024 10:23:25 +0800 (CST) Received: from slurm-master.loongson.cn (unknown [10.10.130.252]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx_c6a6KVl3RwDAA--.16453S4; Tue, 16 Jan 2024 10:23:23 +0800 (CST) From: Jiahao Xu To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, chenglulu@loongson.cn, xuchenghua@loongson.cn, Jiahao Xu Subject: [PATCH] LoongArch: Split vec_selects of bottom elements into simple move Date: Tue, 16 Jan 2024 10:23:20 +0800 Message-Id: <20240116022320.51782-1-xujiahao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cx_c6a6KVl3RwDAA--.16453S4 X-CM-SenderInfo: 50xmxthkdrqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7AF4kur1xGF1fXrW8Cw47Jrc_yoW8ury3pa y7uwnrKF48JFZ7K3WkGayUXw13Wr9FgFW3ZF9xury2kFy7XryqvFW0krZIqFy5Zw4Yqr1a vF4fuw4UWw43K3gCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j8yCJUUUUU= X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788212002540659344 X-GMAIL-MSGID: 1788212002540659344 For below pattern, can be treated as a simple move because floating point and vector share a common register on loongarch64. (set (reg/v:SF 32 $f0 [orig:93 res ] [93]) (vec_select:SF (reg:V8SF 32 $f0 [115]) (parallel [ (const_int 0 [0]) ]))) gcc/ChangeLog: * config/loongarch/lasx.md (vec_extract_0): New define_insn_and_split patten. gcc/testsuite/ChangeLog: * gcc.target/loongarch/vect-extract.c: New test. diff --git a/gcc/config/loongarch/lasx.md b/gcc/config/loongarch/lasx.md index 72f7161311c..90f66ee4d24 100644 --- a/gcc/config/loongarch/lasx.md +++ b/gcc/config/loongarch/lasx.md @@ -761,6 +761,21 @@ (define_expand "vec_extract" DONE; }) +(define_insn_and_split "vec_extract_0" + [(set (match_operand: 0 "register_operand" "=f") + (vec_select: + (match_operand:FLASX 1 "register_operand" "f") + (parallel [(const_int 0)])))] + "ISA_HAS_LSX" + "#" + "&& reload_completed" + [(set (match_dup 0) (match_dup 1))] +{ + operands[1] = gen_rtx_REG (mode, REGNO (operands[1])); +} + [(set_attr "move_type" "fmove") + (set_attr "mode" "")]) + (define_expand "vec_perm" [(match_operand:LASX 0 "register_operand") (match_operand:LASX 1 "register_operand") diff --git a/gcc/testsuite/gcc.target/loongarch/vect-extract.c b/gcc/testsuite/gcc.target/loongarch/vect-extract.c new file mode 100644 index 00000000000..ce126e3a4f1 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/vect-extract.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -mlasx -fno-vect-cost-model -fno-unroll-loops" } */ +/* { dg-final { scan-assembler-not "xvpickve.w" } } */ +/* { dg-final { scan-assembler-not "xvpickve.d" } } */ + +float +sum_float (float *a, int n) { + float res = 0.0; + for (int i = 0; i < n; i++) + res += a[i]; + return res; +} + +double +sum_double (double *a, int n) { + double res = 0.0; + for (int i = 0; i < n; i++) + res += a[i]; + return res; +}