From patchwork Fri Apr 14 02:45:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 83196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp86193vqo; Thu, 13 Apr 2023 19:46:40 -0700 (PDT) X-Google-Smtp-Source: AKy350ZmkK+y9aomHq80+/nY6vC8xxuOmoInbu5005AN+AC4vHJ2BnNlv87h6a9UxyZsRIVf7gHj X-Received: by 2002:a17:906:d189:b0:934:2fe4:4921 with SMTP id c9-20020a170906d18900b009342fe44921mr4671808ejz.19.1681440400294; Thu, 13 Apr 2023 19:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681440400; cv=none; d=google.com; s=arc-20160816; b=y3Xht4U0QAkWosP5VYKlo8hN0iQFKwCgO8+G4LGUdYOAmh4fl5Ti+32ev+0tHFKFvl uGIlM8Oa/e3fms2tmfoPQEnjJul76CbGGGw9BS4bRPfm0SCajGO2aBcv8DX+8cKrg5fA dVc9uZuaymi/4YAapwgK/Q23b4uYr2yFMEmNrwUmp590/Cih0qON7PoEm4RssmfQs6pl aK/ptrLbdeglmHmfCN74AlUziLJ131xSBq6Q/3CcKzLAyS2/uIPggU6HZOTeD4QMQW+g HS1LUvOU3Bs6Qsq069Hi6gt093mthx0/908FffzijmChhLoeULcLzaNXGSzOAj52Bg+n pKDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=djkJUcGKhC5/APfHxy7ULfsn7rH7a0rnATRIw0e0JPc=; b=zjQXwM5eUS7De5k0IQd/9V5jIIqZJkCk9w27y3Dzxzc0jqQFjAKst6OlGmonRN1xxC cGeHTeMriBUlFjXooMLbWu2pC+kAoNppzhudqrSNH1lTr+5MKGzDNsi4iddn2GLCKcYZ HHuJvan549qsUwaZDFsAXaOTqCySlLuD68TpVntSY2mFNr1glCLj2rr+W5UZy9zMnyuf c0XyMJoM9qfE4QPKjIZiKkilGe4Hh+993yD5g7+fw1oBuP88IfAvNCkSSlbaX2LLVDLm z9Y95j0JDh5s0/1E409ZJttqDjiXld3AzzvwwhnU8IZQzL8LqMoqQR+ITBn3y91tq33/ 4gSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="EE/gaSXK"; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h19-20020a17090791d300b0094a4c68c578si3424254ejz.240.2023.04.13.19.46.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 19:46:40 -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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="EE/gaSXK"; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC9323858C54 for ; Fri, 14 Apr 2023 02:46:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC9323858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681440399; bh=djkJUcGKhC5/APfHxy7ULfsn7rH7a0rnATRIw0e0JPc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=EE/gaSXKCdgqLcHZg2OAQVl0eupDcf40YJ3yW+I6Elx42v5ZsG8sUNpL0ec0PFO7q hhgeaDEtzt6fzb75w7Uhg9IKlX/z8m9BAPr9B/DJbdgb+CDiQRAGx7mZI8fPh+eORK lhMYXhce28zBem5fzMmV2xrNHkYszIWNZoRYSos8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 75F773858D33 for ; Fri, 14 Apr 2023 02:45:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75F773858D33 X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="430661665" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="430661665" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 19:45:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="935847785" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="935847785" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by fmsmga006.fm.intel.com with ESMTP; 13 Apr 2023 19:45:32 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.46.88]) by shvmail02.sh.intel.com (Postfix) with ESMTP id 8C3651007EBE; Fri, 14 Apr 2023 10:45:31 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, yanzhang.wang@intel.com, pan2.li@intel.com Subject: [PATCH v2] RISC-V: Add test cases for the RVV mask insn shortcut. Date: Fri, 14 Apr 2023 10:45:29 +0800 Message-Id: <20230414024529.2930664-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414023238.2921142-1-pan2.li@intel.com> References: <20230414023238.2921142-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pan Li via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: pan2.li@intel.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763117224328996346?= X-GMAIL-MSGID: =?utf-8?q?1763118048783900142?= From: Pan Li There are sorts of shortcut codegen for the RVV mask insn. For example. vmxor vd, va, va => vmclr vd. We would like to add more optimization like this but first of all we must add the tests for the existing shortcut optimization, to ensure we don't break existing optimization from underlying shortcut optimization. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/mask_insn_shortcut.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- .../riscv/rvv/base/mask_insn_shortcut.c | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/mask_insn_shortcut.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/mask_insn_shortcut.c b/gcc/testsuite/gcc.target/riscv/rvv/base/mask_insn_shortcut.c new file mode 100644 index 00000000000..efc3af39fc3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/mask_insn_shortcut.c @@ -0,0 +1,239 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +vbool1_t test_shortcut_for_riscv_vmand_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmand_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmand_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmand_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmand_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmand_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmand_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmand_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmand_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmand_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmand_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmand_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmand_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmand_mm_b64(v1, v1, vl); +} + +vbool1_t test_shortcut_for_riscv_vmnand_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmnand_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmnand_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmnand_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmnand_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmnand_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmnand_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmnand_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmnand_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmnand_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmnand_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmnand_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmnand_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmnand_mm_b64(v1, v1, vl); +} + +vbool1_t test_shortcut_for_riscv_vmandn_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmandn_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmandn_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmandn_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmandn_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmandn_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmandn_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmandn_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmandn_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmandn_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmandn_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmandn_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmandn_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmandn_mm_b64(v1, v1, vl); +} + +vbool1_t test_shortcut_for_riscv_vmxor_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmxor_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmxor_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmxor_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmxor_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmxor_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmxor_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmxor_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmxor_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmxor_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmxor_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmxor_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmxor_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmxor_mm_b64(v1, v1, vl); +} + +vbool1_t test_shortcut_for_riscv_vmor_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmor_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmor_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmor_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmor_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmor_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmor_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmor_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmor_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmor_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmor_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmor_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmor_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmor_mm_b64(v1, v1, vl); +} + +vbool1_t test_shortcut_for_riscv_vmnor_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmnor_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmnor_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmnor_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmnor_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmnor_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmnor_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmnor_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmnor_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmnor_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmnor_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmnor_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmnor_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmnor_mm_b64(v1, v1, vl); +} + +vbool1_t test_shortcut_for_riscv_vmorn_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmorn_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmorn_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmorn_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmorn_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmorn_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmorn_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmorn_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmorn_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmorn_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmorn_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmorn_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmorn_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmorn_mm_b64(v1, v1, vl); +} + +vbool1_t test_shortcut_for_riscv_vmxnor_case_0(vbool1_t v1, size_t vl) { + return __riscv_vmxnor_mm_b1(v1, v1, vl); +} + +vbool2_t test_shortcut_for_riscv_vmxnor_case_1(vbool2_t v1, size_t vl) { + return __riscv_vmxnor_mm_b2(v1, v1, vl); +} + +vbool4_t test_shortcut_for_riscv_vmxnor_case_2(vbool4_t v1, size_t vl) { + return __riscv_vmxnor_mm_b4(v1, v1, vl); +} + +vbool8_t test_shortcut_for_riscv_vmxnor_case_3(vbool8_t v1, size_t vl) { + return __riscv_vmxnor_mm_b8(v1, v1, vl); +} + +vbool16_t test_shortcut_for_riscv_vmxnor_case_4(vbool16_t v1, size_t vl) { + return __riscv_vmxnor_mm_b16(v1, v1, vl); +} + +vbool32_t test_shortcut_for_riscv_vmxnor_case_5(vbool32_t v1, size_t vl) { + return __riscv_vmxnor_mm_b32(v1, v1, vl); +} + +vbool64_t test_shortcut_for_riscv_vmxnor_case_6(vbool64_t v1, size_t vl) { + return __riscv_vmxnor_mm_b64(v1, v1, vl); +} + +/* { dg-final { scan-assembler-not {vmand\.mm\s+v[0-9]+,\s*v[0-9]+} } } */ +/* { dg-final { scan-assembler-not {vmnand\.mm\s+v[0-9]+,\s*v[0-9]+} } } */ +/* { dg-final { scan-assembler-not {vmnandn\.mm\s+v[0-9]+,\s*v[0-9]+} } } */ +/* { dg-final { scan-assembler-not {vmxor\.mm\s+v[0-9]+,\s*v[0-9]+} } } */ +/* { dg-final { scan-assembler-not {vmor\.mm\s+v[0-9]+,\s*v[0-9]+} } } */ +/* { dg-final { scan-assembler-not {vmnor\.mm\s+v[0-9]+,\s*v[0-9]+} } } */ +/* { dg-final { scan-assembler-times {vmorn\.mm\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 7 } } */ +/* { dg-final { scan-assembler-not {vmxnor\.mm\s+v[0-9]+,\s*v[0-9]+} } } */ +/* { dg-final { scan-assembler-times {vmclr\.m\s+v[0-9]+} 14 } } */ +/* { dg-final { scan-assembler-times {vmset\.m\s+v[0-9]+} 7 } } */