From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe35.google.com (mail-vs1-xe35.google.com [IPv6:2607:f8b0:4864:20::e35]) by sourceware.org (Postfix) with ESMTPS id A454D3858D37 for ; Mon, 23 Oct 2023 09:22:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A454D3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A454D3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::e35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698052976; cv=none; b=fR/OdcMXx+GYZNzWzUVibhzrA3zee5iQwXLdhp/Sh5IJ490LRsPe86lfUixSfZ6niToAqaq5IcEIyiySatnF5tdUy6LyhkQRb5O3VT1W4/MGbO4nS4qKc5WqoKe4u7jeo5/cQEOj668CxeZP15N6uAOoNeT28u5QFppUytCglHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698052976; c=relaxed/simple; bh=PAcF07j9Is/ohSI7K9awDFzWyJN7wHca3jLb63ICG3c=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=FZrPhanSWmOW3NDmFX8Cirui4HyAUH7ppF08RoSznsjBneptlSGpwYMFbqG2bK7dzZwugRNLua6HEQAB/OLb90cafPyy+z1bNzK82DfX00+ToZBu5CJhaIPdo0xHw6heM2gBJ7TSpMN7+nnPpKxFWK/Qyuyl/qvWS78ehmOEx7Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vs1-xe35.google.com with SMTP id ada2fe7eead31-457cb2fe3abso1254890137.3 for ; Mon, 23 Oct 2023 02:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698052974; x=1698657774; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YJm9LepjL6R3gBE1S35c68uAGHQumv2SAFoVi1sI4cc=; b=B+5Npi7EEaHLqVN4B+PEcHsX4Lcm08g348TqDhiGFDlVz0qDdQjKAVBIIhg7UydJiX dsD9emfPpMMgmUrb+6m6TP/yBNNUzDPO+1aMASbNKtWpb6wuTDLuHe7fXp6aBoPmgnOz 8DPBS0A25OqIKxptJFB1fXUVnzT/reWaNCWSzb2aNu47mvZVKsQgmlMg4C5+qct261uS TU3GQYvAiFPm2s83tuIBmwVk/O/Bc2szYd7iL3BqyyU/vhEx/NB9nxlv1VXS6hJm0WHA vOi69WpLHxNG+1vfZZJyqto6hjY0gDNXuf6zAs7/50QfVbsOBOWQkSxYZbILgJkE6ZJY NNvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698052974; x=1698657774; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YJm9LepjL6R3gBE1S35c68uAGHQumv2SAFoVi1sI4cc=; b=aTBc3RZYzJVdXtQlPtlhb/H+L6mQPZ2mlmy+wHpY0oAkrPSENdNRbaj8O2eFF0nEKQ aRp7GeX2uiUZieLCk0/kH6lK9313+D3AqhFD6JhJkf61WSFq6WUDRof0AehDc9KFxdAq U8mqFg5kx0mYKteoUlYA76YhRojZoHpVgCyvsbHgu5SSpvoh6KidKfvzoaA6GOQSTEwB WlTH1RLdkptIwBezgoEAY8mGR0fguruQkjhsC/izT+lhZhqBTRJ/qNWhw7pHofxfQDB5 Vxzs/v8Ej0owvtYEqLbdJ1muxZucuno8/cNf1R1idjoAqKBRi0BTkC62wKzX+lzJZXix yVeA== X-Gm-Message-State: AOJu0Yy7dJ/NsMzadnXitU0Xg/v2laslQAjVPfXiLEPTxHKrURqk/WzG zK1vw9YKsccHdpCAS0cqEmhZxmbGp/qt5ow6fL0= X-Google-Smtp-Source: AGHT+IFTDA9r4S+aKY88z8AkX2uQE+rXaL5f09Jhh2eVmNaRQmXLkdnoT9lTWa/qMZ2B241I9tCRbtqlSGQYm+fTJyU= X-Received: by 2002:a05:6102:20dc:b0:452:66a7:1ac with SMTP id i28-20020a05610220dc00b0045266a701acmr8188503vsr.6.1698052973772; Mon, 23 Oct 2023 02:22:53 -0700 (PDT) MIME-Version: 1.0 References: <20231023090401.1724890-1-juzhe.zhong@rivai.ai> In-Reply-To: <20231023090401.1724890-1-juzhe.zhong@rivai.ai> From: Kito Cheng Date: Mon, 23 Oct 2023 17:22:42 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: Fix ICE for the fusion case from vsetvl to scalar move[PR111927] To: Juzhe-Zhong Cc: gcc-patches@gcc.gnu.org, kito.cheng@sifive.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,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 List-Id: Few minor comments: On Mon, Oct 23, 2023 at 5:04=E2=80=AFPM Juzhe-Zhong = wrote: > > ICE: > > during RTL pass: vsetvl > : In function 'riscv_lms_f32': > :240:1: internal compiler error: in merge, at config/riscv/riscv-= vsetvl.cc:1997 > 240 | } > > In general compatible_p (avl_equal_p) has: > > if (next.has_vl () && next.vl_used_by_non_rvv_insn_p ()) > return false; > > Don't fuse AVL of vsetvl if the VL operand is used by non-RVV instructrio= ns. instructrions -> instructions > > It is reasonable to add it into 'can_use_next_avl_p' since we don't want = to > fuse AVL of vsetvl into a scalar move instruction which doesn't demand AV= L. > And after the fusion, we will alway use compatible_p to check whether the= demand > is correct or not. > > PR target/111927 > > gcc/ChangeLog: > > * config/riscv/riscv-vsetvl.cc: Fix ICE. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/rvv/vsetvl/pr111927.c: New test. > > --- > gcc/config/riscv/riscv-vsetvl.cc | 23 ++ > .../gcc.target/riscv/rvv/vsetvl/pr111927.c | 243 ++++++++++++++++++ > 2 files changed, 266 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr111927.c > > diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vs= etvl.cc > index 47b459fddd4..42295732ed7 100644 > --- a/gcc/config/riscv/riscv-vsetvl.cc > +++ b/gcc/config/riscv/riscv-vsetvl.cc > @@ -1541,6 +1541,29 @@ private: > inline bool can_use_next_avl_p (const vsetvl_info &prev, > const vsetvl_info &next) > { > + /* Forbid the AVL/VL propagation if VL of NEXT is used > + by non-RVV instructions. This is because: > + > + bb 2: > + scalar move (no AVL) Could you add few comment to mention this is prev > + bb 3: > + vsetvl a5(VL), a4(AVL) ... and this is next > + branch a5,zero > + > + Since user vsetvl instruction is no side effect instruction > + which should be placed in the correct and optimal location > + of the program by the previous PASS, it is unreasonble that unreasonble -> unreasonable > + VSETVL PASS tries to move it to another places if it used by > + non-RVV instructions. > + > + Note: We only forbid the cases that VL is used by the following > + non-RVV instructions which will cause issues. We don't forbid > + other cases since it won't cause correctness issues and we still > + more more demand info are fused backward. The later LCM algorith= m more more -> more > + should know the optimal location of the vsetvl. */ > + if (next.has_vl () && next.vl_used_by_non_rvv_insn_p ()) > + return false; > + > if (!next.has_nonvlmax_reg_avl () && !next.has_vl ()) > return true; > > diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr111927.c b/gcc/t= estsuite/gcc.target/riscv/rvv/vsetvl/pr111927.c > new file mode 100644 > index 00000000000..62f395fee33 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr111927.c > @@ -0,0 +1,243 @@ > +/* { dg-do compile } */ > +/* { dg-options "-march=3Drv64gcv -mabi=3Dlp64d -O3" } */ > + > +#include "riscv_vector.h" > +#include Including stdio.h will cause multi-lib testing issues, and I don't saw any function or declaration defined in stdio.h are used in the file, so I assume this is safe to remove and could you clean up the testcase? at least drop those unused #else parts= ?