From patchwork Sat Sep 2 04:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Jie X-Patchwork-Id: 137416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c792:0:b0:3f2:4152:657d with SMTP id b18csp1292968vqu; Fri, 1 Sep 2023 21:49:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwgdt+JHR15VlSupHORZl27bD29ygLAJt6zV/7BoGTBRy4gwVdK8KCpUYoCKV+PtvjIRIR X-Received: by 2002:a05:6512:3082:b0:4ff:7e04:7575 with SMTP id z2-20020a056512308200b004ff7e047575mr3687615lfd.14.1693630156853; Fri, 01 Sep 2023 21:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693630156; cv=none; d=google.com; s=arc-20160816; b=qNUA/HExpSFcvd8QODCDsdkWgMWpIeJeriTBnvND7Pbgel5TqUZwfCmCBczqglqPTg M8ZVpo2mR74Y7MoQrqZhN5GUVf5WtBC40WYUgcGxfnZRGRgtdW3Uzw9FiIQr7yOyR0Wk UBk6r5izDZcG9r3n9YdR22mKugSbPjq1kRsWhGTqZQ4U92RzZPnVxDGOaQCSaOM3XQTn y0kSH4e0W48m2tPrA7SPXdHmfc0BxR3PtIAlkqv0cUab+vc7z/OppNPtlQZspNx0x04Z Z6zjR3Xdwr5LLn/hQEPYRtFEldqUUNFZm4T+siYVc1o29jPWWsRpIPdRA5BaIXBWX00B vnWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dmarc-filter :delivered-to; bh=h9YQ7j2RA5qEWGo0PFCfFcm/VYiyF/Kv9qLxY0FYfII=; fh=WfH4Rd7KtWp1EjXjTdii7qoKjQ8oEJ7/9jnEjH+Yg58=; b=ugazu67gupT+NB8FLIQAfaIdy1H3UPrN7brtEtcYmhjBhO4kKW0Tc8n7T5N656Owd/ ZXPZ5Eu+IwkduTnGp0RlEFeOre7YIb11+SCco27aocE8EDc85zUe+tALCjWpq1nM9tFN x0fySd49vQsOmRKEyAcVd/e6VxAGDWNqLFLmzp2/WQl9ZG+4SwU0Bn8AsWrEZBUe3z+u o4XAPZjQpDc1PQu4jvhby4RrUGHawHktslZgETQNU1GZmKNms48wQerSmYpUmBOuXK7z N1DAHmLvfO0MJTkwKyEjatp4Kv13n/CXG//qHPlWFMqjesNvmXy5neqvFVSRTdjCciRt 4xCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n2-20020aa7c442000000b005254dd9d233si3250256edr.464.2023.09.01.21.49.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 21:49:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 2CBBE3857737 for ; Sat, 2 Sep 2023 04:49:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id EB5483858D1E for ; Sat, 2 Sep 2023 04:48:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB5483858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=loongson.cn Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcIYn-0003Ib-5x for gcc-patches@gcc.gnu.org; Sat, 02 Sep 2023 00:48:40 -0400 Received: from loongson.cn (unknown [10.20.4.191]) by gateway (Coremail) with SMTP id _____8Cxh+iVvvJk4_MdAA--.25630S3; Sat, 02 Sep 2023 12:48:22 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.191]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxzM5+vvJk4HVpAA--.58244S4; Sat, 02 Sep 2023 12:48:21 +0800 (CST) From: Guo Jie To: gcc-patches@gcc.gnu.org Subject: [PATCH] LoongArch: Support loading floating-point zero into MEM[base + index]. Date: Sat, 2 Sep 2023 12:47:39 +0800 Message-Id: <20230902044739.28996-1-guojie@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxzM5+vvJk4HVpAA--.58244S4 X-CM-SenderInfo: xjxryx3h6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxAw1kJrWUKr4UZFW3tF15Jrc_yoW5ZFykp3 95Aw1Fgw48Grnakw15Aay7Jws8CF1IkF4a9FWaqr9Ikayagr18ZF4rA3sIvFy5Cw1FqryF vr4Sgw45Zr4rKwbCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07UNvtZUUUUU= Received-SPF: pass client-ip=114.242.206.163; envelope-from=guojie@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_FAIL, SPF_HELO_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: , Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, i@xen0n.name, Guo Jie Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775899935315616453 X-GMAIL-MSGID: 1775899935315616453 gcc/ChangeLog: * config/loongarch/loongarch.md: Support 'G' -> 'k' in movsf_hardfloat and movdf_hardfloat. gcc/testsuite/ChangeLog: * gcc.target/loongarch/const-double-zero-stx.c: New test. --- gcc/config/loongarch/loongarch.md | 12 ++++++------ .../loongarch/const-double-zero-stx.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/const-double-zero-stx.c diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index b37e070660f..6f47c23a79c 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -1915,13 +1915,13 @@ (define_expand "movsf" }) (define_insn "*movsf_hardfloat" - [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,f,k,m,*f,*r,*r,*r,*m") - (match_operand:SF 1 "move_operand" "f,G,m,f,k,f,G,*r,*f,*G*r,*m,*r"))] + [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,f,k,m,k,*f,*r,*r,*r,*m") + (match_operand:SF 1 "move_operand" "f,G,m,f,k,f,G,G,*r,*f,*G*r,*m,*r"))] "TARGET_HARD_FLOAT && (register_operand (operands[0], SFmode) || reg_or_0_operand (operands[1], SFmode))" { return loongarch_output_move (operands[0], operands[1]); } - [(set_attr "move_type" "fmove,mgtf,fpload,fpstore,fpload,fpstore,store,mgtf,mftg,move,load,store") + [(set_attr "move_type" "fmove,mgtf,fpload,fpstore,fpload,fpstore,store,store,mgtf,mftg,move,load,store") (set_attr "mode" "SF")]) (define_insn "*movsf_softfloat" @@ -1946,13 +1946,13 @@ (define_expand "movdf" }) (define_insn "*movdf_hardfloat" - [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,f,k,m,*f,*r,*r,*r,*m") - (match_operand:DF 1 "move_operand" "f,G,m,f,k,f,G,*r,*f,*r*G,*m,*r"))] + [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,f,k,m,k,*f,*r,*r,*r,*m") + (match_operand:DF 1 "move_operand" "f,G,m,f,k,f,G,G,*r,*f,*r*G,*m,*r"))] "TARGET_DOUBLE_FLOAT && (register_operand (operands[0], DFmode) || reg_or_0_operand (operands[1], DFmode))" { return loongarch_output_move (operands[0], operands[1]); } - [(set_attr "move_type" "fmove,mgtf,fpload,fpstore,fpload,fpstore,store,mgtf,mftg,move,load,store") + [(set_attr "move_type" "fmove,mgtf,fpload,fpstore,fpload,fpstore,store,store,mgtf,mftg,move,load,store") (set_attr "mode" "DF")]) (define_insn "*movdf_softfloat" diff --git a/gcc/testsuite/gcc.target/loongarch/const-double-zero-stx.c b/gcc/testsuite/gcc.target/loongarch/const-double-zero-stx.c new file mode 100644 index 00000000000..8fb04be8ff5 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/const-double-zero-stx.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times {stx\..\t\$r0} 2 } } */ + +extern float arr_f[]; +extern double arr_d[]; + +void +test_f (int base, int index) +{ + arr_f[base + index] = 0.0; +} + +void +test_d (int base, int index) +{ + arr_d[base + index] = 0.0; +}