From patchwork Thu May 11 03:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 92351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4085974vqo; Wed, 10 May 2023 20:41:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5r6Nn437q6WMB84KerjF217y5lgXE9L/Pg5HGjQZVyE0F8fUV0UiWVV6A1O8VmiKRvkrZo X-Received: by 2002:a17:907:a04:b0:94a:8291:a1e3 with SMTP id bb4-20020a1709070a0400b0094a8291a1e3mr15838392ejc.74.1683776491709; Wed, 10 May 2023 20:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683776491; cv=none; d=google.com; s=arc-20160816; b=fP2zEMgLXNBrAI57DfnEQ4isFIE9+ihPbkvexrFPoyGYvRc3Nw48FYVtPq2RTSbAmi 1cGo/1IHd6RCNy1/tGCS1V+L+Ed+jvl2+3u4W96Rd89fFLmZObHYOiV3oJbk2ydhdMoc 4RdIuQiQwfCMagCRRPAFp1ZswQrPWaGoSNpXiGKyiMY356QAnc/UC7g3vmsc1ilqJtvh yPWsecTyliYEDBzGw/uxf448TpWz8UhjApkAy/pVwB6ckx+GV8TAgBa9NNhcDhnUO2k9 2RNhYQi6Sr5K17iauH2y+w4l1MFlfLDYHdGy5yvKpeuOSBcvU37UjKQc5Nq3ag2ZLmZl spOg== 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:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=xtFEV/Gwl+2qnZupVKLIQd+Nm20kJIx1FWNNnE87rFQ=; b=ouQvx6JKttfSh/hwaYprYFt5OIeFX/zNr09JsqicM6Es+w8ARdBb2PgwfMgqK4UlRL KYCPLi1hlg0tKPPylu+kNZL9QTDEvuEVjDlXGaFLy8eIy6TBlI2z5qX6p4xDSb2/TtDA gDz1TCprS0g2Af9liR/316mPklkKTNM1BQjb5cyIMHFhGqhn1NQCUtqDyewgLKcP/aK7 b/tBshJUtYj2a1EJDuTuhlwJHcOcH1oXpWlOsX3lQ/j4QG3FQxJpqlhVjaCYt5UyJArx 8B/eUauDVrT6GG3k2FfskIQXEpiFoLbbEUNbaXT0zpoZYHYpgIB1wcbdSuMegsen2/Ff 5gMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Q3pFmLos; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fy24-20020a1709069f1800b00969f26bad70si3894653ejc.306.2023.05.10.20.41.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 20:41:31 -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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Q3pFmLos; 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"; 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 869A23857024 for ; Thu, 11 May 2023 03:41:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 869A23857024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683776490; bh=xtFEV/Gwl+2qnZupVKLIQd+Nm20kJIx1FWNNnE87rFQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Q3pFmLosAFonBnphasIaT5UUnf+2ZO3bR5KL+R6wiwnZczI1d+M4OmEhmxz/ZHFkK ZrDxX7BTUhJxBR+DBwCy5X2Wa1jZDs1XjV6A+qV51o3UUY+vEeCtU3Be9MukhQ0/ej pl8vaJyuCifn3mNFVXwU2qUdj1s0AUPg62032GXQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 49AD13858D33 for ; Thu, 11 May 2023 03:40:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49AD13858D33 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-530638a60e1so1060344a12.2 for ; Wed, 10 May 2023 20:40:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683776442; x=1686368442; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xtFEV/Gwl+2qnZupVKLIQd+Nm20kJIx1FWNNnE87rFQ=; b=TVWd5lazEQ41VV7zIqmdwUNu3QXbdjRJLoR0t1yt+jZKo1jIJdeSY9LzxP1sE5TjRs 2LZN+py3b//0raf2Q5xiltT9p8TwXXj9684rAzSsAGNv8S6XwHAImYOKMK6ksH93Vr5B TMaM17TlB0R7hOLJt4Wils4mueRianY6NuR6EwZ+3wBSCY90ws//lKRQ9JtB2o+M3YJ5 W7V2G+vWFDyuwjTefk2KBs9ojGYoubQ3O7df+P/EPxxLS3xun89fUDqHCk1dRas1eFM2 lpfgrbYYWIyr06b6WEGf0AlixpKKK+hZJw2hCXWQQvkA+4UPzm1mEcgCJgPmAuw6TA7/ 93bA== X-Gm-Message-State: AC+VfDz5bwHw233363CIJ/43mdgYwNY/MbEXvMjFgOGr+nhbWMhMBI0O 2ECOdjhhXcr+TqPu4ekTGnXl9KWTe7+8aneBSlLQBgI0TzXrFt2sKCnwNG6r+SwP+02xfNFBMSm plKk9psLyNH2BYgoKZIW46ET1HDAt02NMlo0NGal5Ee2+c9PyDSUI5bYM5jHtkBqtqmmf/sduC/ mBF/c= X-Received: by 2002:a17:902:d512:b0:1ab:723:1acc with SMTP id b18-20020a170902d51200b001ab07231accmr24809004plg.35.1683776441642; Wed, 10 May 2023 20:40:41 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id j11-20020a170902da8b00b001aafde15ff3sm825822plx.293.2023.05.10.20.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 20:40:41 -0700 (PDT) To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, rdapp.gcc@gmail.com Cc: Juzhe-Zhong Subject: [committed v2] RISC-V: Support const series vector for RVV auto-vectorization Date: Thu, 11 May 2023 11:38:30 +0800 Message-Id: <20230511033829.39575-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT 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: Kito Cheng via Gcc-patches From: Kito Cheng Reply-To: Kito Cheng 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?1765478268563540465?= X-GMAIL-MSGID: =?utf-8?q?1765567618407637355?= From: Juzhe-Zhong Off line discussed with Ju-Zhe, and send and committed by me because he got some network issue. V2 Changes: - Code restructure and rename emit_indexop to emit_index_op. - Minor comment tweak. --- This patch is the prerequiste patch for more RVV auto-vectorization support. Since when we enable a very simple binary operations, we will end up with such following ICE: during RTL pass: expand add_run-1.c: In function 'main': add_run-1.c:28:1: internal compiler error: Segmentation fault 0x1618ea3 crash_signal ../../../riscv-gcc/gcc/toplev.cc:314 0xe76cd9 single_set(rtx_insn const*) ../../../riscv-gcc/gcc/rtl.h:3602 0x1080f8a emit_move_insn(rtx_def*, rtx_def*) ../../../riscv-gcc/gcc/expr.cc:4342 0x170c458 insert_value_copy_on_edge ../../../riscv-gcc/gcc/tree-outof-ssa.cc:352 0x170d58e eliminate_phi ../../../riscv-gcc/gcc/tree-outof-ssa.cc:785 0x170df17 expand_phi_nodes(ssaexpand*) ../../../riscv-gcc/gcc/tree-outof-ssa.cc:1024 0xef27e2 execute ../../../riscv-gcc/gcc/cfgexpand.cc:6818 This is because LoopVectorizer assume target is able to handle series const vector when we enable binary operations. Then it will be easily causing ICE like that. gcc/ChangeLog: * config/riscv/autovec.md (@vec_series): New pattern * config/riscv/riscv-protos.h (expand_vec_series): New function. * config/riscv/riscv-v.cc (emit_binop): Ditto. (emit_index_op): Ditto. (expand_vec_series): Ditto. (expand_const_vector): Add series vector handling. * config/riscv/riscv.cc (riscv_const_insns): Enable series vector for testing. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/series-1.c: New test. * gcc.target/riscv/rvv/autovec/series_run-1.c: New test. --- gcc/config/riscv/autovec.md | 24 ++++ gcc/config/riscv/riscv-protos.h | 1 + gcc/config/riscv/riscv-v.cc | 118 +++++++++++++++++- gcc/config/riscv/riscv.cc | 27 +++- .../gcc.target/riscv/rvv/autovec/series-1.c | 50 ++++++++ .../riscv/rvv/autovec/series_run-1.c | 20 +++ 6 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/series-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/series_run-1.c diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index f1c5ff5951bf..99dc4f046b0c 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -58,3 +58,27 @@ DONE; } ) + +;; ========================================================================= +;; == Vector creation +;; ========================================================================= + +;; ------------------------------------------------------------------------- +;; ---- [INT] Linear series +;; ------------------------------------------------------------------------- +;; Includes: +;; - vid.v +;; - vmul.vx +;; - vadd.vx/vadd.vi +;; ------------------------------------------------------------------------- + +(define_expand "@vec_series" + [(match_operand:VI 0 "register_operand") + (match_operand: 1 "reg_or_int_operand") + (match_operand: 2 "reg_or_int_operand")] + "TARGET_VECTOR" + { + riscv_vector::expand_vec_series (operands[0], operands[1], operands[2]); + DONE; + } +) diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index c0293a306f92..e8a728ae226f 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -219,6 +219,7 @@ rtx gen_avl_for_scalar_move (rtx); void expand_tuple_move (machine_mode, rtx *); machine_mode preferred_simd_mode (scalar_mode); opt_machine_mode get_mask_mode (machine_mode); +void expand_vec_series (rtx, rtx, rtx); } /* We classify builtin types into two classes: diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 7ca49ca67c18..381e6601a174 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -248,6 +248,111 @@ emit_nonvlmax_op (unsigned icode, rtx dest, rtx src, rtx len, emit_pred_op (icode, NULL_RTX, dest, src, len, mask_mode, false); } +/* Emit binary operations. */ + +static void +emit_binop (unsigned icode, rtx *ops, machine_mode mask_mode, + machine_mode scalar_mode) +{ + insn_expander<9> e; + machine_mode mode = GET_MODE (ops[0]); + e.add_output_operand (ops[0], mode); + e.add_all_one_mask_operand (mask_mode); + e.add_vundef_operand (mode); + if (VECTOR_MODE_P (GET_MODE (ops[1]))) + e.add_input_operand (ops[1], GET_MODE (ops[1])); + else + e.add_input_operand (ops[1], scalar_mode); + if (VECTOR_MODE_P (GET_MODE (ops[2]))) + e.add_input_operand (ops[2], GET_MODE (ops[2])); + else + e.add_input_operand (ops[2], scalar_mode); + rtx vlmax = gen_reg_rtx (Pmode); + emit_vlmax_vsetvl (mode, vlmax); + e.add_input_operand (vlmax, Pmode); + e.add_policy_operand (get_prefer_tail_policy (), get_prefer_mask_policy ()); + e.add_avl_type_operand (avl_type::VLMAX); + e.expand ((enum insn_code) icode, false); +} + +/* Emit vid.v instruction. */ + +static void +emit_index_op (rtx target, machine_mode mask_mode) +{ + insn_expander<7> e; + machine_mode mode = GET_MODE (target); + e.add_output_operand (target, mode); + e.add_all_one_mask_operand (mask_mode); + e.add_vundef_operand (mode); + rtx vlmax = gen_reg_rtx (Pmode); + emit_vlmax_vsetvl (mode, vlmax); + e.add_input_operand (vlmax, Pmode); + e.add_policy_operand (get_prefer_tail_policy (), get_prefer_mask_policy ()); + e.add_avl_type_operand (avl_type::VLMAX); + e.expand (code_for_pred_series (mode), false); +} + +/* Expand series const vector. */ + +void +expand_vec_series (rtx dest, rtx base, rtx step) +{ + machine_mode mode = GET_MODE (dest); + machine_mode inner_mode = GET_MODE_INNER (mode); + machine_mode mask_mode; + gcc_assert (get_mask_mode (mode).exists (&mask_mode)); + + /* VECT_IV = BASE + I * STEP. */ + + /* Step 1: Generate I = { 0, 1, 2, ... } by vid.v. */ + rtx vid = gen_reg_rtx (mode); + emit_index_op (vid, mask_mode); + + /* Step 2: Generate I * STEP. + - STEP is 1, we don't emit any instructions. + - STEP is power of 2, we use vsll.vi/vsll.vx. + - STEP is non-power of 2, we use vmul.vx. */ + rtx step_adj; + if (rtx_equal_p (step, const1_rtx)) + step_adj = vid; + else + { + step_adj = gen_reg_rtx (mode); + if (CONST_INT_P (step) && pow2p_hwi (INTVAL (step))) + { + /* Emit logical left shift operation. */ + int shift = exact_log2 (INTVAL (step)); + rtx shift_amount = gen_int_mode (shift, Pmode); + rtx ops[3] = {step_adj, vid, shift_amount}; + insn_code icode = code_for_pred_scalar (ASHIFT, mode); + emit_binop (icode, ops, mask_mode, Pmode); + } + else + { + rtx ops[3] = {step_adj, vid, step}; + insn_code icode = code_for_pred_scalar (MULT, mode); + emit_binop (icode, ops, mask_mode, inner_mode); + } + } + + /* Step 3: Generate BASE + I * STEP. + - BASE is 0, use result of vid. + - BASE is not 0, we use vadd.vx/vadd.vi. */ + if (rtx_equal_p (base, const0_rtx)) + { + emit_move_insn (dest, step_adj); + } + else + { + rtx result = gen_reg_rtx (mode); + rtx ops[3] = {result, step_adj, base}; + insn_code icode = code_for_pred_scalar (PLUS, mode); + emit_binop (icode, ops, mask_mode, inner_mode); + emit_move_insn (dest, result); + } +} + static void expand_const_vector (rtx target, rtx src, machine_mode mask_mode) { @@ -280,12 +385,19 @@ expand_const_vector (rtx target, rtx src, machine_mode mask_mode) return; } + /* Support scalable const series vector. */ + rtx base, step; + if (const_vec_series_p (src, &base, &step)) + { + emit_insn (gen_vec_series (mode, target, base, step)); + return; + } + /* TODO: We only support const duplicate vector for now. More cases will be supported when we support auto-vectorization: - 1. series vector. - 2. multiple elts duplicate vector. - 3. multiple patterns with multiple elts. */ + 1. multiple elts duplicate vector. + 2. multiple patterns with multiple elts. */ } /* Expand a pre-RA RVV data move from SRC to DEST. diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index ff90c44d811b..84e9267bcb21 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -1266,9 +1266,34 @@ riscv_const_insns (rtx x) } case CONST_DOUBLE: - case CONST_VECTOR: /* We can use x0 to load floating-point zero. */ return x == CONST0_RTX (GET_MODE (x)) ? 1 : 0; + case CONST_VECTOR: + { + /* TODO: This is not accurate, we will need to + adapt the COST of CONST_VECTOR in the future + for the following cases: + + - 1. const duplicate vector with element value + in range of [-16, 15]. + - 2. const duplicate vector with element value + out range of [-16, 15]. + - 3. const series vector. + ...etc. */ + if (riscv_v_ext_vector_mode_p (GET_MODE (x))) + { + /* const series vector. */ + rtx base, step; + if (const_vec_series_p (x, &base, &step)) + { + /* This is not accurate, we will need to adapt the COST + * accurately according to BASE && STEP. */ + return 1; + } + } + /* TODO: We may support more const vector in the future. */ + return x == CONST0_RTX (GET_MODE (x)) ? 1 : 0; + } case CONST: /* See if we can refer to X directly. */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/series-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/series-1.c new file mode 100644 index 000000000000..a01f6ce7411a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/series-1.c @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32d --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4" } */ + +#include + +#define NUM_ELEMS(TYPE) (64 / sizeof (TYPE)) + +#define DEF_LOOP(TYPE, BASE, STEP, SUFFIX) \ + void __attribute__ ((noinline, noclone)) \ + loop_##TYPE##_##SUFFIX (TYPE *restrict a) \ + { \ + for (int i = 0; i < NUM_ELEMS (TYPE); ++i) \ + a[i] = (BASE) + i * (STEP); \ + } + +#define TEST_SEW32_TYPES(T, BASE, STEP, SUFFIX) \ + T (uint32_t, BASE, STEP, SUFFIX) \ + T (int32_t, BASE, STEP, SUFFIX) + +#define TEST_ALL(T) \ + TEST_SEW32_TYPES (T, 0, 1, b0s1) \ + TEST_SEW32_TYPES (T, 0, 2, b0s2) \ + TEST_SEW32_TYPES (T, 0, 3, b0s3) \ + TEST_SEW32_TYPES (T, 0, 8, b0s8) \ + TEST_SEW32_TYPES (T, 0, 9, b0s9) \ + TEST_SEW32_TYPES (T, 0, 16, b0s16) \ + TEST_SEW32_TYPES (T, 0, 17, b0s17) \ + TEST_SEW32_TYPES (T, 0, 32, b0s32) \ + TEST_SEW32_TYPES (T, 0, 33, b0s33) \ + TEST_SEW32_TYPES (T, -16, 1, bm16s1) \ + TEST_SEW32_TYPES (T, 15, 1, b15s1) \ + TEST_SEW32_TYPES (T, -17, 1, bm17s1) \ + TEST_SEW32_TYPES (T, 16, 1, b16s1) \ + TEST_SEW32_TYPES (T, -16, 128, bm16s128) \ + TEST_SEW32_TYPES (T, 15, 128, b15s128) \ + TEST_SEW32_TYPES (T, -17, 128, bm17s128) \ + TEST_SEW32_TYPES (T, 16, 128, b16s128) \ + TEST_SEW32_TYPES (T, -16, 179, bm16s179) \ + TEST_SEW32_TYPES (T, 15, 179, b15s179) \ + TEST_SEW32_TYPES (T, -17, 179, bm17s179) \ + TEST_SEW32_TYPES (T, 16, 179, b16s179) \ + TEST_SEW32_TYPES (T, -16, 65536, bm16s65536) \ + TEST_SEW32_TYPES (T, 15, 65536, b15s65536) \ + TEST_SEW32_TYPES (T, -17, 65536, bm17s65536) \ + TEST_SEW32_TYPES (T, 16, 65536, b16s65536) + +TEST_ALL (DEF_LOOP) + +/* { dg-final { scan-assembler-times {vid\.v\s+v[0-9]+} 50 } } */ +/* { dg-final { scan-assembler-times {vsll\.vi\s+v[0-9]+} 24 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/series_run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/series_run-1.c new file mode 100644 index 000000000000..09a20809c65c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/series_run-1.c @@ -0,0 +1,20 @@ +/* { dg-do run { target { riscv_vector } } } */ +/* { dg-options "--param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4" } */ + +#include "series-1.c" + +#define TEST_LOOP(TYPE, BASE, STEP, SUFFIX) \ + { \ + TYPE array[NUM_ELEMS (TYPE)] = {}; \ + loop_##TYPE##_##SUFFIX (array); \ + for (int i = 0; i < NUM_ELEMS (TYPE); i++) \ + if (array[i] != (TYPE) (BASE + i * STEP)) \ + __builtin_abort (); \ + } + +int __attribute__ ((optimize (1))) +main () +{ + TEST_ALL (TEST_LOOP) + return 0; +}