From patchwork Wed Dec 6 07:04:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiahao Xu X-Patchwork-Id: 17597 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3929139vqy; Tue, 5 Dec 2023 23:05:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9bgLbfH3zxkLaH3B7W5D2N+Xhq0lct85m64fC8ZGVByr943fwn3BxN/prSAuT8v/2yVXo X-Received: by 2002:ad4:5ca1:0:b0:67a:caa5:66d1 with SMTP id q1-20020ad45ca1000000b0067acaa566d1mr500193qvh.4.1701846324387; Tue, 05 Dec 2023 23:05:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701846324; cv=pass; d=google.com; s=arc-20160816; b=QxBfWd6UrZxtRkWhQYfFpntN8vFYH0UNkOa6v2HCYVk4m5wta4C8sKEm01iztenSSq Cl3i3gSIfbQCzEiebVoPxP5WO30L9DTfV8cbMJZe2kuLJskwA/3JpjGPfGrPssmfru5j OqjhM8rDgw3zR0EiW2gc8NE5FehNqRQFfyesm48ZRLg6IU4XV01GgY7C60LBs6rNwNq8 kkl1yggKEUCPiAL+FgLoITYvp2rj/zddPX+DP9TnGga9Af8ZEaun7gwuhvR4jjoa6chB blif2iRX+3+Jk6fyxbbxyo6wv3Ujlr8cqXZWkR0ywJudiDoVvSnoRbo86HPdRjbqPY4C w1IQ== 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=YJCkKLRfaeQ0SKiN9cMIS8ptlTIBlv4RiW/JOKKt9tg=; fh=w+xsGLuzpTj56E0bzPMCc39RWHkBXt2f2AGs+4pGimo=; b=Gg4QHjR/bl16+vFMpjL7/i5+912P+ZCDdSFdBKLyr/PbGxXnyJoAddoJwY1qrcabkA SgmYoKDF7MKBV4e/bwx6cx0X5siRuToPLKdrEAX2ExzeDXE/N/dcoSuiwS/0fYKh5b+r vZACtTNaego1XCwcbd1JfcPfC/8V0u2EKs1Wo1taMmNybZXH2ekLiUY0wj89Hjj1zVfV 6M+s4PKaup6VFR4SKJ/1FmQ4Qr+sg2VTGZi97ObWYg6lFLvR4NjQyydgKnRw6uXsb2DL cTe1PIXYF10iwlIxjDVcoBuXAgX7AnxTX7ayLy5O1xTvCgOsjES41nKdiT1LHbPU4U2E 1vgQ== 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 c3-20020a056214070300b0065b087a5385si13516137qvz.431.2023.12.05.23.05.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 23:05:24 -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 29F18386D636 for ; Wed, 6 Dec 2023 07:05:24 +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 470DD3858C54 for ; Wed, 6 Dec 2023 07:04:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 470DD3858C54 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 470DD3858C54 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=1701846301; cv=none; b=mAOX/uyxGwkva86qqrfgq+LT/844q4XdeyWW7UYpCWN6c/5fCcTnfjA6ga5p1Pfh7Ss9YUIKEc4RwLadAP7SwtpCDfH6rXJXZNQlRmJuFkIou5ZliyHT57Qqp1ly9WDD2liJoT97Zeh+8fyE4qDosrCVA7twTV83N5NJJaIye3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701846301; c=relaxed/simple; bh=LqeFnfVWAvTicVwT90l+0KhtzZAmA0Uuh5wRPFsqe3g=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=ZYJAaVDlkEzIRAtsAfWt/nfJa8Oj59LyycBOJl/Ae+72DyKBDDhzVOpRKnRwcy6nRAVEl3hMZfxMmMAQft4335TdUdaq2P63bw/gDZH645dkE/IYWIljJcJNtf5KUcYuTKGo5qXlujch2KYyQ8eY9COFjC9Qz8dlhwqgRDodI0M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.10.130.252]) by gateway (Coremail) with SMTP id _____8BxbOoYHXBlOjs_AA--.33181S3; Wed, 06 Dec 2023 15:04:56 +0800 (CST) Received: from slurm-master.loongson.cn (unknown [10.10.130.252]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dxvi8XHXBlp0BWAA--.59594S4; Wed, 06 Dec 2023 15:04:55 +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 v3 0/5] Add support for approximate instructions and optimize divf/sqrtf/rsqrtf operations. Date: Wed, 6 Dec 2023 15:04:48 +0800 Message-Id: <20231206070453.3252-1-xujiahao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Dxvi8XHXBlp0BWAA--.59594S4 X-CM-SenderInfo: 50xmxthkdrqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxurW8Kw15XFyrKryrtr4xAFc_yoWruF1xp3 y7CrnrtF48GFZ3Wr1kJa43XF4DXF97K3ya93Way348CrWIqr9Fv3WktrnxXFy3Ja45Jryx Xwn5uw15W3WYv3XCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jUsqXUUUUU= X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, 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: 1784515211498161975 X-GMAIL-MSGID: 1784515211498161975 LoongArch V1.1 adds support for approximate instructions, which are utilized along with additional Newton-Raphson steps implement single precision floating-point division, square root and reciprocal square root operations for better throughput. The patches are modifications made based on the patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-December/639243.html Jiahao Xu (5): LoongArch: Add support for LoongArch V1.1 approximate instructions. LoongArch: Use standard pattern name for xvfrsqrt/vfrsqrt instructions. LoongArch: Redefine pattern for xvfrecip/vfrecip instructions. LoongArch: New options -mrecip and -mrecip= with ffast-math. LoongArch: Vectorized loop unrolling is disable for divf/sqrtf/rsqrtf when -mrecip is enabled. gcc/config/loongarch/genopts/isa-evolution.in | 1 + gcc/config/loongarch/genopts/loongarch.opt.in | 11 + gcc/config/loongarch/larchintrin.h | 38 +++ gcc/config/loongarch/lasx.md | 89 ++++++- gcc/config/loongarch/lasxintrin.h | 34 +++ gcc/config/loongarch/loongarch-builtins.cc | 66 +++++ gcc/config/loongarch/loongarch-c.cc | 3 + gcc/config/loongarch/loongarch-cpucfg-map.h | 1 + gcc/config/loongarch/loongarch-def.cc | 3 +- gcc/config/loongarch/loongarch-protos.h | 2 + gcc/config/loongarch/loongarch-str.h | 1 + gcc/config/loongarch/loongarch.cc | 252 +++++++++++++++++- gcc/config/loongarch/loongarch.h | 18 ++ gcc/config/loongarch/loongarch.md | 104 ++++++-- gcc/config/loongarch/loongarch.opt | 15 ++ gcc/config/loongarch/lsx.md | 89 ++++++- gcc/config/loongarch/lsxintrin.h | 34 +++ gcc/config/loongarch/predicates.md | 8 + gcc/doc/extend.texi | 35 +++ gcc/doc/invoke.texi | 54 ++++ gcc/testsuite/gcc.target/loongarch/divf.c | 10 + .../loongarch/larch-frecipe-builtin.c | 28 ++ .../gcc.target/loongarch/recip-divf.c | 9 + .../gcc.target/loongarch/recip-sqrtf.c | 23 ++ gcc/testsuite/gcc.target/loongarch/sqrtf.c | 24 ++ .../loongarch/vector/lasx/lasx-divf.c | 13 + .../vector/lasx/lasx-frecipe-builtin.c | 30 +++ .../loongarch/vector/lasx/lasx-recip-divf.c | 12 + .../loongarch/vector/lasx/lasx-recip-sqrtf.c | 28 ++ .../loongarch/vector/lasx/lasx-recip.c | 24 ++ .../loongarch/vector/lasx/lasx-rsqrt.c | 26 ++ .../loongarch/vector/lasx/lasx-sqrtf.c | 29 ++ .../loongarch/vector/lsx/lsx-divf.c | 13 + .../vector/lsx/lsx-frecipe-builtin.c | 30 +++ .../loongarch/vector/lsx/lsx-recip-divf.c | 12 + .../loongarch/vector/lsx/lsx-recip-sqrtf.c | 28 ++ .../loongarch/vector/lsx/lsx-recip.c | 24 ++ .../loongarch/vector/lsx/lsx-rsqrt.c | 26 ++ .../loongarch/vector/lsx/lsx-sqrtf.c | 29 ++ 39 files changed, 1234 insertions(+), 42 deletions(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/divf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/larch-frecipe-builtin.c create mode 100644 gcc/testsuite/gcc.target/loongarch/recip-divf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/recip-sqrtf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/sqrtf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-divf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-frecipe-builtin.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-recip-divf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-recip-sqrtf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-recip.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-rsqrt.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-sqrtf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-divf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-frecipe-builtin.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-recip-divf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-recip-sqrtf.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-recip.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-rsqrt.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-sqrtf.c