From patchwork Sat Sep 2 07:02:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Jie X-Patchwork-Id: 137421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp31021vqo; Sat, 2 Sep 2023 00:04:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYNRmUFAnAxt4QQ7LKwddxD8hYFOAQy5KDIIN3QLUhAfwcJ4ZqFfVXNvwKsfT9SoWklegr X-Received: by 2002:a05:6512:e91:b0:500:adbd:43e7 with SMTP id bi17-20020a0565120e9100b00500adbd43e7mr3810692lfb.8.1693638251540; Sat, 02 Sep 2023 00:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693638251; cv=none; d=google.com; s=arc-20160816; b=CNvISiclJLaqfVPzif+kyQpWXjWtYuIOt5Rm7r+Vw6Bo4kdQcmwlID8Y75IiwGarse c7BgEpS2aUu4hdWZN+6X/8HNL/QC5+o/X97xz+g6a35CGHw0LoXvzVetYKsUx40kt6Ej nSQbtOzRPxDyi39aDJjQ/agZRNXnZB0l1wu6hNLL3x9YijpbDxGhW3whGtr8JLsgv2xU k91ymBgf/28yziE2XSZSrzCAeWQBpCMx7Jxy9ropAPwm/jeUkMEP6hVVH7XeSgCsaqWe QYv4lbKmnS6NbR22s/7Y1wsXSxJ+ucfO0uucm538u+uRJi9vxCQFmFE5JujlDccxrg9W 76cQ== 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=bhwt/nEJ1OfQN1LDNnrm/8NJEuEL0r85gXad+1n/KuE=; fh=WfH4Rd7KtWp1EjXjTdii7qoKjQ8oEJ7/9jnEjH+Yg58=; b=EsBvblAuF5LYhoYZ2lzJ5XUsKsv1JMA8eHW9AhR7sHlULn5RAvGoUqcSoqFURFKvBg 8jfk+Vhj39hwMn0gebuEFLsf5OunkYBVmXEG0EcE3vZQlxOoNIQ/F6c04Myx9aUOoiiP WrrrvD3CJ3C9GyEp/8pQQ6HbRG/zCWpEZYX3JjMcSOUfq4kFvyUDImsWKPbPGEcV/99l hSYCTIQpenI8j02vlLf8SiyZOUrrA3/eJXzrdcF0z6BB2xaT+wyXoUCJ2RsO8cAj0oqa qQFM2wnhhahRAJ3QBKrvM++YhKbY8WJoLsRTlh6lJMRvhdfpWDCwtWZsxVNIv+CGxmdl fAgw== ARC-Authentication-Results: i=1; mx.google.com; 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 n11-20020aa7db4b000000b005255eec879esi3499115edt.64.2023.09.02.00.04.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 00:04:11 -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; 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 C47753858296 for ; Sat, 2 Sep 2023 07:04:04 +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 708A53858D20 for ; Sat, 2 Sep 2023 07:03:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 708A53858D20 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 1qcKfP-0002CL-EP for gcc-patches@gcc.gnu.org; Sat, 02 Sep 2023 03:03:39 -0400 Received: from loongson.cn (unknown [10.20.4.191]) by gateway (Coremail) with SMTP id _____8DxRvE+3vJkxvkdAA--.61265S3; Sat, 02 Sep 2023 15:03:27 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.191]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxWM0j3vJk14JpAA--.60387S4; Sat, 02 Sep 2023 15:03:25 +0800 (CST) From: Guo Jie To: gcc-patches@gcc.gnu.org Subject: [PATCH v2] LoongArch: Support storing floating-point zero into MEM[base + index]. Date: Sat, 2 Sep 2023 15:02:07 +0800 Message-Id: <20230902070207.31651-1-guojie@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxWM0j3vJk14JpAA--.60387S4 X-CM-SenderInfo: xjxryx3h6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxAw1kJrWUKr4UZFW3tF15Jrc_yoW5Zw45p3 95Aw1Fgw48Grnakw15Aay7Jws8CF1IkF4a9FWaqr9Ikayagr18ZF4rA3sIvFy5Ww1FqryF vr4Sgw45Zr4rKwbCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07URa0PUUUUU= 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: 1775908423066910493 X-GMAIL-MSGID: 1775908423066910493 v2: Modify commit message. 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; +}