From patchwork Mon Oct 16 02:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiahao Xu X-Patchwork-Id: 15389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3188767vqb; Sun, 15 Oct 2023 19:00:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvg/MIjb+EQqHlTLkkaQMHk+5r0IFIi4tj8pBnmRDO3K5S4hVOQpmLPZn46zysidNNy0v9 X-Received: by 2002:a05:620a:370f:b0:76c:e86f:ffe3 with SMTP id de15-20020a05620a370f00b0076ce86fffe3mr40986273qkb.5.1697421655817; Sun, 15 Oct 2023 19:00:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697421655; cv=pass; d=google.com; s=arc-20160816; b=LsQN5mmmD26yw9ljEp7RO12O8aQ/ByV1Azd9GoixBNs+xEBwF9DmQdBCauio9pEb0u fuRwj9Ts2SfSJ4vyqm5OjFs36hzJKeuPXg1BNtNmQfPE6Rl05JivkY2W/EnVogs68M4k 8UsjyCorr6y3dy+ZTRnpmz/BPhYMTl/mkBqpncRj1M6XFjX2XTUWz2F23YCYxbZBWrQ+ eiPgMIFIlnvDwnGsWef/c3vMeIsmKUp7sz0y9VtwR+xkQhikhnU4bN2+qQFM4C7FJJMq rZIyGTI9vJ6g3u98l+kIWFTgXHWU6we1n1Aqs+0d82jRrxKaY9PcxUIG8SvttiZ7UCyp DxWQ== 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=kmZfJ+G5TTpWE3D5PFpatntUmK49Dh7PKKcgHini4jc=; fh=w+xsGLuzpTj56E0bzPMCc39RWHkBXt2f2AGs+4pGimo=; b=Tpoj06aQPnRe/+AsFrF4G79DDBww5Pa9ok0fqU0mhAgkU2IJcNwpVIQO0CbtVB/WIC 1SOMXuB/Sv7y/n/gDs7GOvL46kBB4qt4Ak06RcmMWdZC2muhCzC0l1deD71/Lvf86ib2 vzisYzxIK90xN2Bjy7+jb6gQN5XZ8VUbYquAeLZdxnRIRMfCek1fi+FVhUKVLKrBV9vt uW9aS80wtT8MTvp9mEYa+e78GQn9mNv4xnJPFIatAevH4SUjbs+ryVHsNKw9qWVK44k1 Zg+MGYh+95TGLcMMSqZ2SgICYMDRKOqrC0cD9YccwQ719nh0ih6aO4ERyEFLBnadeRKx 5sIw== 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 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 h22-20020a05620a401600b0076ccd0b58e3si4948100qko.358.2023.10.15.19.00.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 19:00:55 -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; arc=pass (i=1); 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 95EDA385840D for ; Mon, 16 Oct 2023 02:00:55 +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 48FF23858D32 for ; Mon, 16 Oct 2023 02:00:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48FF23858D32 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 48FF23858D32 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=1697421629; cv=none; b=JeitHrfHngVOagdhlNhlKZZqYItRqwVfqtxvMJCLnyn4HZZb410LzjAhF6g0kh9SOrSTgTonyyuZm59UUpX0eXclvBKeXR89LQKlqjQh5Xv2SWJoiCAqOu3KZeD/qM31wXmZxJ83RuN4SVwhcqERf/gSLp92olhTa+yYcGHVAOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697421629; c=relaxed/simple; bh=OpUgmG0HgOAnptYL3IOqzKSX9rg/Xozxpm/Kxu8dOGw=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=jZSKs3Kaq1eQ0DY4G22yfJvsWBicLQvUX5VkJUOem4ywUqCGTGn/OLmHMPTrMgRkcvcQ1Cv9Qy91ssvNj0eW+z3ervKUTiE7ousALTOXIVv1YywFXIKHUZhJ25PqK83y2kIGh05Vnsq/0zoggbcVRwz+YOVAf5H/O7ezp+fbeo0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.10.130.252]) by gateway (Coremail) with SMTP id _____8CxyOgymSxl4DkyAA--.61015S3; Mon, 16 Oct 2023 10:00:18 +0800 (CST) Received: from slurm-master.loongson.cn (unknown [10.10.130.252]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxbNwvmSxlz_4lAA--.14027S4; Mon, 16 Oct 2023 10:00:15 +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 0/3] Optimize loongarch vector implementation. Date: Mon, 16 Oct 2023 10:00:11 +0800 Message-Id: <20231016020014.41979-1-xujiahao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxbNwvmSxlz_4lAA--.14027S4 X-CM-SenderInfo: 50xmxthkdrqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7AryDGr15CFyrWF15XFy5trc_yoW5Jr47p3 y7ZrnxtF48GrZ7Gr1kXa4aqrs0yr97WrWa93W3try8CrWSqry7ZF18t3srXF13Ja15XryS qr1fuw1UW3Wav3cCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUzZ2-UUUUU X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779875610023536254 X-GMAIL-MSGID: 1779875610023536254 The following three patches further enhance loongarch’s vectorization capabilities. Patch one add LoongArch support for AVG_CEIL/FLOOR. Patch 2 add LoongArch support for vec_widen_mult/add/sub_lo/hi patterns. patch 3 make loongarch use the new vector hooks and implements the costing function determine_suggested_unroll_factor, to make it be able to suggest the unroll factor for a given loop being vectorized base vec_ops analysis during vector costing and the available issue information.The patch also adjusts cost model through performance analysis. Jiahao Xu (3): LoongArch:Implement avg and sad standard names. LoongArch:Implement vec_widen standard names. LoongArch:Implement the new vector cost model framework. gcc/config/loongarch/genopts/loongarch.opt.in | 15 +- gcc/config/loongarch/lasx.md | 156 ++++++++- gcc/config/loongarch/loongarch-protos.h | 1 + gcc/config/loongarch/loongarch.cc | 309 +++++++++++++++++- gcc/config/loongarch/loongarch.md | 2 + gcc/config/loongarch/loongarch.opt | 15 +- gcc/config/loongarch/lsx.md | 74 +++++ gcc/doc/invoke.texi | 7 + .../gcc.target/loongarch/avg-ceil-lasx.c | 22 ++ .../gcc.target/loongarch/avg-ceil-lsx.c | 22 ++ .../gcc.target/loongarch/avg-floor-lasx.c | 22 ++ .../gcc.target/loongarch/avg-floor-lsx.c | 22 ++ gcc/testsuite/gcc.target/loongarch/sad-lasx.c | 20 ++ gcc/testsuite/gcc.target/loongarch/sad-lsx.c | 20 ++ .../gcc.target/loongarch/vect-widen-add.c | 26 ++ .../gcc.target/loongarch/vect-widen-mul.c | 26 ++ .../gcc.target/loongarch/vect-widen-sub.c | 26 ++ 17 files changed, 746 insertions(+), 39 deletions(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/avg-ceil-lasx.c create mode 100644 gcc/testsuite/gcc.target/loongarch/avg-ceil-lsx.c create mode 100644 gcc/testsuite/gcc.target/loongarch/avg-floor-lasx.c create mode 100644 gcc/testsuite/gcc.target/loongarch/avg-floor-lsx.c create mode 100644 gcc/testsuite/gcc.target/loongarch/sad-lasx.c create mode 100644 gcc/testsuite/gcc.target/loongarch/sad-lsx.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vect-widen-add.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vect-widen-mul.c create mode 100644 gcc/testsuite/gcc.target/loongarch/vect-widen-sub.c