From patchwork Fri Apr 7 01:21:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 80595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1412723vqo; Thu, 6 Apr 2023 18:22:10 -0700 (PDT) X-Google-Smtp-Source: AKy350YwonpZp2ZR805JY+MPASh+ktBCHzItmu5gqSGXJKXJQUTI6fCI2oYeK2HZOL5roL3L/t8d X-Received: by 2002:a17:906:e257:b0:930:27c2:6d8d with SMTP id gq23-20020a170906e25700b0093027c26d8dmr756699ejb.61.1680830530208; Thu, 06 Apr 2023 18:22:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680830530; cv=none; d=google.com; s=arc-20160816; b=Ie6MZ8TwrEIGbGshxKoqOMco+R97d7eD0Kt3Z80tRlRLhIRLhbkw5/MAocXP7eF37F iakGySbKZ3i4xo6uZQVW+ucnvAhUEOb8+t6wzwTaPs5CSSL7Mjm9TScjblpxMgKUmuZS OvtwZXMv3mEO+gQtUCfro6r9X+uD1ofpqtEiLkxfzP81UgMvyKAGp6rsgqCrevWtbOeL pK0WgAj7aRpuw1KYW9Ihs/ykJONsKNxfL/YWH+Mm4Y3wYOvvrR4YbSjnB+1U/OwcfmVv WLZZF33YZBcSuih28xI8U2JChMKLzi0xTUGIFDuLvU3GPU/Bb9ptpJkFFA79nZ4vNnki ekQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=Qu6P7MKZUm3mtQk4VKgzLMnztqBy4GXQj75pvN0AzDo=; b=dgVA3lxRxq4eNqfCH+aFBly4y20cB768IrBoe/LrJKARv6j38JRWd7lv9Oax4V/rZo ktuBU1bf6avNxyHFZghLpFVrHZiZYQ4B6PWY4EvH1ROlUaAGQ8yiAUCsMOeJGvVRlj74 aVz1mMBh0Q9eBGB3+8mTwT8rZbe8bhnmeCDa/5WGEe3A707UODrbLyFVE7jzguvdSHBJ II9DG3l4XrkI/GSjnVCbi85e7k4rCkE0hnZbsysjI2UnnCtENmiKUGOdDMpO1O8709Dp F0IVhnIRkXeWS4b7r/7PoLb+uABAdK4iwhwa7hI/oVE9dlRk0nsdPTkkw8+1Ckp/e3ou d7DA== 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gb7-20020a170907960700b0093af9e3ac1dsi1323075ejc.46.2023.04.06.18.22.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 18:22:10 -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 D31213857701 for ; Fri, 7 Apr 2023 01:22:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by sourceware.org (Postfix) with ESMTPS id DA2623858D32 for ; Fri, 7 Apr 2023 01:21:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA2623858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp73t1680830491t9ybj07a Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 07 Apr 2023 09:21:30 +0800 (CST) X-QQ-SSF: 01400000000000F0O000000A0000000 X-QQ-FEAT: RmDZc/K2LPFpfYwOYFTDqgXvdz/Q3HNXNMiqGDFH9NcMTmFvZASpyOg/Ll+BJ BFKDqd3Lt7BNfUycC/r6/0dkObNiqAgwQcuOriOPasxuPq+S0cYIsWvEDKDqc6nQwgWZzuS C6Ru89HFktZdpJahrqMoJzZldM1KuN5I9Yo1EJag+s+1nvN0rgmc/kLabGCjyBocmcFH4hR XwttsuKWeNmIOIM7QeRWS0Up5t/wC0ygz6dy/myHG7cqZp7cGWGMwpFSfVtC0S60DHg8gbc A0UorbbXUIUTFT/unH1ix4frps43zxGLym8LkI4ndgoSZ6Tpa9NYtAqc89NXfnlDiAsgLMO oBaESnbHn5mGifDwW5nGQJdGB/ZTLf9LEJIZjhe4BGHGxCR/2X9JoRZhNCEybBWpdyVTlD8 X-QQ-GoodBg: 2 X-BIZMAIL-ID: 10647198826086533420 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Add RVV auto-vectorization compile option Date: Fri, 7 Apr 2023 09:21:29 +0800 Message-Id: <20230407012129.63142-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, TXREP, T_SPF_HELO_TEMPERROR 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: , 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?1762478553942720967?= X-GMAIL-MSGID: =?utf-8?q?1762478553942720967?= From: Juzhe-Zhong The next patch to enable basic RVV auto-vectorization of VLA auto-vectorization (RVV_SCALABLE) and fixed-length VLS auto-vectorization (RVV_FIXED_VLMAX). We will support RVV_FIXED_VLMIN in the future. gcc/ChangeLog: * config/riscv/riscv-opts.h (enum riscv_autovec_preference_enum): Add RVV auto-vectorization compile option. (enum riscv_autovec_lmul_enum): Ditto. * config/riscv/riscv.opt: Ditto. --- gcc/config/riscv/riscv-opts.h | 15 ++++++++++++++ gcc/config/riscv/riscv.opt | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h index cf0cd669be4..4207db240ea 100644 --- a/gcc/config/riscv/riscv-opts.h +++ b/gcc/config/riscv/riscv-opts.h @@ -67,6 +67,21 @@ enum stack_protector_guard { SSP_GLOBAL /* global canary */ }; +/* RISC-V auto-vectorization preference. */ +enum riscv_autovec_preference_enum { + NO_AUTOVEC, + RVV_SCALABLE, + RVV_FIXED_VLMAX +}; + +/* RISC-V auto-vectorization RVV LMUL. */ +enum riscv_autovec_lmul_enum { + RVV_M1 = 1, + RVV_M2 = 2, + RVV_M4 = 4, + RVV_M8 = 8 +}; + #define MASK_ZICSR (1 << 0) #define MASK_ZIFENCEI (1 << 1) diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index ff1dd4ddd4f..ef1bdfcfe28 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -254,3 +254,40 @@ Enum(isa_spec_class) String(20191213) Value(ISA_SPEC_CLASS_20191213) misa-spec= Target RejectNegative Joined Enum(isa_spec_class) Var(riscv_isa_spec) Init(TARGET_DEFAULT_ISA_SPEC) Set the version of RISC-V ISA spec. + +Enum +Name(riscv_autovec_preference) Type(enum riscv_autovec_preference_enum) +The RISC-V auto-vectorization preference: + +EnumValue +Enum(riscv_autovec_preference) String(none) Value(NO_AUTOVEC) + +EnumValue +Enum(riscv_autovec_preference) String(scalable) Value(RVV_SCALABLE) + +EnumValue +Enum(riscv_autovec_preference) String(fixed-vlmax) Value(RVV_FIXED_VLMAX) + +-param=riscv-autovec-preference= +Target RejectNegative Joined Enum(riscv_autovec_preference) Var(riscv_autovec_preference) Init(NO_AUTOVEC) +-param=riscv-autovec-preference= Set the preference of auto-vectorization in the RISC-V port. + +Enum +Name(riscv_autovec_lmul) Type(enum riscv_autovec_lmul_enum) +The RVV possible LMUL: + +EnumValue +Enum(riscv_autovec_lmul) String(m1) Value(RVV_M1) + +EnumValue +Enum(riscv_autovec_lmul) String(m2) Value(RVV_M2) + +EnumValue +Enum(riscv_autovec_lmul) String(m4) Value(RVV_M4) + +EnumValue +Enum(riscv_autovec_lmul) String(m8) Value(RVV_M8) + +-param=riscv-autovec-lmul= +Target RejectNegative Joined Enum(riscv_autovec_lmul) Var(riscv_autovec_lmul) Init(RVV_M1) +-param=riscv-autovec-lmul= Set the RVV LMUL of auto-vectorization in the RISC-V port.