From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 241703858D20 for ; Fri, 5 May 2023 14:20:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 241703858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-50bd87539c2so2928708a12.0 for ; Fri, 05 May 2023 07:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683296436; x=1685888436; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=0OGR8KURdxNBwhckaeK4TGfnmfJs/J1JrthyZiDzg+4=; b=qb4kJNSt4VxHNUPLKNG0ZkAVVo7P9W9s5DHEc3GkvXJjGRVS17SCVcSTPhLc+IRZ6N WKIitO17yG+nF4hGhAKVU/m+cNNr/bn2ElXuKB7ocEzdqg7P0wRTWVCHZOaeZ1fSO25w Rzcjc5VJ39HrxEYlHeeLbWvuwBz5UROAhLpnGUcq2zGIxK78IfzlsdZrlL7/5+x8RICR Sv6wjqQTJI4zLP+TG5oUEy1dl/24YqCIGWU8qw+/me8fvjbsCzIeg9Bx2lDOuFN9xdw6 UATmjJfX0RrFDDWhQvttx7yTnKkf6pwCg/fUEWiug5/u/5056yYpHSMQVg6MeY/V3qJ5 VDNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683296436; x=1685888436; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0OGR8KURdxNBwhckaeK4TGfnmfJs/J1JrthyZiDzg+4=; b=YoB1RB/AicEdYTVlkoADdBSvWMrtzkkC7IHG4oTEZhHZoi/ieOncmewgOsohbUd6O/ pGpX2R4DP4PPGKMI6pTXL1iQ6porGc5iYSV5dzTjztQVtc42mDXvkQMZIYMGXLOKtrrx EcPNJ1FdXF+P9clWBLNwZjrKjq4biHwpc0TELM2GP1XoOUuAfVKf5zVAC4rG6CUvCGKP 5UDfdfCDKKhqJB7FhqFNMBnMUsOXWGwzqVD5hXupQmplcE1QV6DeOsRnV0DEjgNISMIJ 2I/sRBBWhn+dKGkoYSxnjSDgeJqQXxEAiFZb6BzwqhxY9YOx/nh9Ap1YPIaebOz09Luj l2pw== X-Gm-Message-State: AC+VfDzOR1lPiRpDKEQgd9Fxf0A+Un2tqymvm4WbczM6+myHxCYzPq5x IwrTZOAltU86PDwymMNXTY4= X-Google-Smtp-Source: ACHHUZ4O5GAH2e11sbbE3Djt5FyrxU0hwpfr6fCQsSHkpgCs3AVutzN3W6VSubdJps2sJ//YVnqarg== X-Received: by 2002:aa7:ce0a:0:b0:506:af22:1271 with SMTP id d10-20020aa7ce0a000000b00506af221271mr1651680edv.0.1683296435487; Fri, 05 May 2023 07:20:35 -0700 (PDT) Received: from [192.168.1.23] (ip-046-005-130-086.um12.pools.vodafone-ip.de. [46.5.130.86]) by smtp.gmail.com with ESMTPSA id l12-20020aa7c30c000000b0050690bc07a3sm2959841edq.18.2023.05.05.07.20.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 May 2023 07:20:34 -0700 (PDT) Message-ID: <7b4dd4f9-7dcf-4dec-6704-8edc774ca122@gmail.com> Date: Fri, 5 May 2023 16:20:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH V3] RISC-V: Enable basic RVV auto-vectorization support. To: juzhe.zhong@rivai.ai, gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com References: <20230504054544.203366-1-juzhe.zhong@rivai.ai> Content-Language: en-US From: Robin Dapp In-Reply-To: <20230504054544.203366-1-juzhe.zhong@rivai.ai> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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 List-Id: Hi Juzhe, I wasn't yet able to check this locally so just some minor comment nits: > +/* Return the vectorization machine mode for RVV according to LMUL. */ > +machine_mode > +preferred_simd_mode (scalar_mode mode) > +{ > + /* We only enable auto-vectorization when TARGET_MIN_VLEN < 128 && > + riscv_autovec_lmul < RVV_M2. Since GCC loop vectorizer report ICE when we > + enable -march=rv64gc_zve32* and -march=rv32gc_zve64*. in the I believe Kito mentioned this in the last iteration but the comment here doesn't match the code below. You want >= 128 instead of < 128. > + /* TODO: Currently, it will produce ICE for --param > + riscv-autovec-preference=fixed-vlmax. So, we just return NULL_RTX here > + let GCC genearte loads/stores. Ideally, GCC should either report > + Warning message to tell user do not use RVV vector type in function > + arg, or GCC just support function arg calling convention for RVV > + directly. */ > + if (riscv_v_ext_mode_p (mode)) > + return NULL_RTX; will produce -> will cause an ICE genearte -> generate GCC should either... -> we should either warn the user not to use an RVV vector type as function argument ... or support the calling convention.... > +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/fixed-vlmax-1.c > @@ -0,0 +1,22 @@ > +/* { dg-do compile } */ > +/* { dg-options "-march=rv32gcv -mabi=ilp32 -mpreferred-stack-boundary=3 -fno-schedule-insns -fno-schedule-insns2 -O3 --param riscv-autovec-preference=fixed-vlmax" } */ > + > +#include "riscv_vector.h" > + > +void f (char*); > + > +void stach_check_alloca_1 (vuint8m1_t data, uint8_t *base, int y, ...) > +{ Shouldn't that be stack rather than stach? > +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/single_rgroup-1.h > @@ -0,0 +1,106 @@ > +#include > +#include > + > +#define N 777 > + > +#define test_1(TYPE) \ > + TYPE a_##TYPE[N]; \ > + TYPE b_##TYPE[N]; \ > + void __attribute__ ((noinline, noclone)) test_1_##TYPE (unsigned int n) \ Just FYI, you can use ((noipa)) to cover all cases of unwanted "inlining". Not needed here though. > diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/v-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/v-1.c > new file mode 100644 > index 00000000000..7ff84f60749 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/v-1.c > @@ -0,0 +1,4 @@ > +/* { dg-do compile } */ > +/* { dg-options "-march=rv32gcv -mabi=ilp32d --param riscv-autovec-preference=scalable -O3 -ftree-vectorize -fdump-tree-vect-details -save-temps" } */ > + > +#include "template-1.h" I'm a bit wary of these tests not checking anything. Of course we will see if we ICE or not but that I would expect from a "new feature". Couldn't we check something else at least that gives a clue as to what is supposed to happen? Last time I tried some of those locally, we would not vectorize. In case that's intended we could check for e.g. "vectorized 0 loops in function". If not, a comment would still help. Do we actually need -ftree-vectorize at -O3? In general I would prefer to split off common options and set them in rvv.exp already, only giving dg-additional-options for each test. Here we don't share too many apart from -O3 -ftree-vectorize so not yet necessary. Regards Robin