From patchwork Mon Dec 11 05:19:19 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: 176475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6841956vqy; Sun, 10 Dec 2023 21:19:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiKU+v35HREFhhLdqNKOsQEYJEzjRLvcvI9M77+CcYjLROqzTv7buiyCyMJBpt4gh4cEba X-Received: by 2002:ac8:5948:0:b0:425:a7ae:5cc5 with SMTP id 8-20020ac85948000000b00425a7ae5cc5mr5313159qtz.36.1702271994929; Sun, 10 Dec 2023 21:19:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702271994; cv=pass; d=google.com; s=arc-20160816; b=rOd09UfSI4KFnXuAuupLYWUoBLYXVtklUFUZghOkBvbLpqQyaKaPHV+e43vhrSJebr rwWQYbpufGS3PO/8dnvmeeheIS3WIkjwZLr+HBJ+neP28U17Q7W980ugGNp6HVcLjwB4 1YKnGJwcTIViC74H9dQso2cO2QzB9GIanuykCawW6UJylknlUpFkRFLJmVoF9v5y/YvL 7w7L42g7OyeepD8YBihsolFGWM9LPZv/bPS4b4fb3t0QNaK5Kxj7elB/VdPhXDRxAOhC +DF+8ImaAkNXRfmag1zjXVapdOWKhm9akrVJ559HkMd73U3QERGQ2J4BtBCyJQ4Xi3dw JgRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=ywof89AC/pDt9LtlBpwUvsDPOxK/3A+aokw2jBW5DYY=; fh=12MRPJmZ1mgDpHqWoogMKqnaGRGM2b7lcuJroqfjJiw=; b=mcNU+ACmD/K2fH9piMvA25yVqJg3dJBfseA22ZVYXgKUBX/fIbu0rKKfCFLkaosFed /zAh7yw5HsZt9vSvi4GKd+spxxk95JPtxb7emY4il73j/aahTVA/O0ex4CgZIWiVfkjP LXDa+G+sIE8O8C4XzSLn+oNnjZX1AVeLLEezAk/t4TlqZ5jT0+El6mDMamvLTc0nsQXg KunCyQUS15ToC3c6Vp+rvirg9VPR37JJhfb5mNmUr/mO6Ft+unc1+aD/BGg7kRcolu1/ 3gTJ/PbY82VkArt3rsBHmq+3qGaV2Qy8b6SPmv0OVwcmSPWX2ioqsoHN/epei0aHJQml ZbOg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g3-20020ac81243000000b004238ef6941asi7392040qtj.25.2023.12.10.21.19.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 21:19:54 -0800 (PST) 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; arc=pass (i=1); 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 B13AE3857B9C for ; Mon, 11 Dec 2023 05:19:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by sourceware.org (Postfix) with ESMTPS id DA12A3858C3A for ; Mon, 11 Dec 2023 05:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA12A3858C3A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DA12A3858C3A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=54.206.16.166 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702271972; cv=none; b=dEH0G8WK19UBUzfsSFJoBdCgU11ZeLQpKmEeFtnVx0f+i9X7f70ka6zVAn5EBmfIiPMw3342BJWjvWATgdMdFc+KWY4WzI54Em5KR5UIju9d5bNuoP2+1qZgKXieUvE5F5WQx4EHS9xg6Qkbf/1s+SG9oNAu0Mp061wJ3LJ7ejg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702271972; c=relaxed/simple; bh=hQ5oGnZzYlmYHU66T5p3H2fLx9wXL0Ck4uqODOEGCq0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=I6oAUryV+aF+mFCQSbIvedCp98VscZOd659ZIhOSBKtSPYzSuMDVs2u0PQtazqbF1PnML2XBnp6e3kTbvR7e+oYLZzW9pYaoudCBgJumoksWbWkZssPLSFa2n2KPHS6WE1yWMWYzdYsSbxnHg9VlwXExHwqJHbHuTj+cGzeFy78= ARC-Authentication-Results: i=1; server2.sourceware.org X-QQ-mid: bizesmtp64t1702271961tvafj75e Received: from rios-cad122.hadoop.rioslab.org ( [58.60.1.26]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 11 Dec 2023 13:19:20 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: RmDZc/K2LPFN0bSEYZcYkKhLUgOuGclY2UZMmzZ7SZ5age53wdriadlxWxYl5 r/WW28TXEt+yt+orRzNa8eSkW1CXV46XUHhKO1o2BsQDWFzAQK1ohBO6Ey/nuBS5kWP/Wr0 JoV/HyicxMA5dibgdLinMgLYjQbDyKR7UZ+oUxFzYQt5uy9BVwvBfVlWulRMgbCkLFLITEJ TsdwmOOP5CWzfEsxBv61hNbsEJoFaNKOZ8qYlELTUmqjfuYX4fP3AKdcefSf2MZi/vwQcPq sGHT8qs/FjGriDs82kIxVGN+GFzl31hezMDk3M+znov1cZtiWmR3NzY4nz6xU0FQV7NKmZq NMLrwGGgGhxbkt/V22/WJ9vA1IELGCyHrpm3BdlQ0uAzwBy2RiYGfdxL8NIf6lQXueP+vSM 5SZU3zP4aQs= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 15391041712544610794 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Remove poly selftest when --preference=fixed-vlmax Date: Mon, 11 Dec 2023 13:19:19 +0800 Message-Id: <20231211051919.3236502-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:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784961559666290629 X-GMAIL-MSGID: 1784961559666290629 This patch fixes multiple ICEs in full coverage testing: cc1: internal compiler error: in riscv_legitimize_poly_move, at config/riscv/riscv.cc:2456^M 0x1fd8d78 riscv_legitimize_poly_move^M ../../../../gcc/gcc/config/riscv/riscv.cc:2456^M 0x1fd9518 riscv_legitimize_move(machine_mode, rtx_def*, rtx_def*)^M ../../../../gcc/gcc/config/riscv/riscv.cc:2583^M 0x2936820 gen_movdi(rtx_def*, rtx_def*)^M ../../../../gcc/gcc/config/riscv/riscv.md:2099^M 0x11a0f28 rtx_insn* insn_gen_fn::operator()(rtx_def*, rtx_def*) const^M ../../../../gcc/gcc/recog.h:431^M 0x13cf2f9 emit_move_insn_1(rtx_def*, rtx_def*)^M ../../../../gcc/gcc/expr.cc:4553^M 0x13d010c emit_move_insn(rtx_def*, rtx_def*)^M ../../../../gcc/gcc/expr.cc:4723^M 0x216f5e0 run_poly_int_selftest^M ../../../../gcc/gcc/config/riscv/riscv-selftests.cc:185^M 0x21701e6 run_poly_int_selftests^M ../../../../gcc/gcc/config/riscv/riscv-selftests.cc:226^M 0x2172109 selftest::riscv_run_selftests()^M ../../../../gcc/gcc/config/riscv/riscv-selftests.cc:371^M 0x3b8067b selftest::run_tests()^M ../../../../gcc/gcc/selftest-run-tests.cc:112^M 0x1ad90ee toplev::run_self_tests()^M ../../../../gcc/gcc/toplev.cc:2209^M Running target riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medlow/--param=riscv-autovec-lmul=m1/--param=riscv-autovec-preference=fixed-vlmax The rootcause is that we are testing POLY value computation during FIXED-VLMAX and ICE in this code: if (BYTES_PER_RISCV_VECTOR.is_constant ()) { gcc_assert (value.is_constant ()); -----> assert failed. riscv_emit_move (dest, GEN_INT (value.to_constant ())); return; } For example, a poly value [15, 16] is computed by csrr vlen + multiple scalar integer instructions. However, such compile-time unknown value need to be computed when it is scalable vector, that is !BYTES_PER_RISCV_VECTOR.is_constant (), since csrr vlenb = [16, 0] when -march=rv64gcv --param=riscv-autovec-preference=fixed-vlmax and we have no chance to compute compile-time POLY value. Also, we never reach the situation to compute a compile time unknown value when it is FIXED-VLMAX vector. So disable POLY selftest for FIXED-VLMAX. gcc/ChangeLog: * config/riscv/riscv-selftests.cc (riscv_run_selftests): Remove poly self test when FIXED-VLMAX. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/poly-selftest-1.c: New test. --- gcc/config/riscv/riscv-selftests.cc | 14 +++++++++++++- .../gcc.target/riscv/rvv/base/poly-selftest-1.c | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/poly-selftest-1.c diff --git a/gcc/config/riscv/riscv-selftests.cc b/gcc/config/riscv/riscv-selftests.cc index 0ac17fb70a1..289916b999e 100644 --- a/gcc/config/riscv/riscv-selftests.cc +++ b/gcc/config/riscv/riscv-selftests.cc @@ -368,7 +368,19 @@ namespace selftest { void riscv_run_selftests (void) { - run_poly_int_selftests (); + if (!BYTES_PER_RISCV_VECTOR.is_constant ()) + /* We can know POLY value = [4, 4] when BYTES_PER_RISCV_VECTOR + is !is_constant () since we can use csrr vlenb and scalar shift + instruction to compute such POLY value and store it into a scalar + register. Wheras, we can't know [4, 4] on it is specified as + FIXED-VLMAX since BYTES_PER_RISCV_VECTOR = 16 for -march=rv64gcv + and csrr vlenb is 16 which is totally unrelated to any + compile-time unknown POLY value. + + Since we never need to compute a compile-time unknown POLY value + when --param=riscv-autovec-preference=fixed-vlmax, disable poly + selftests in such situation. */ + run_poly_int_selftests (); run_const_vector_selftests (); run_broadcast_selftests (); } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/poly-selftest-1.c b/gcc/testsuite/gcc.target/riscv/rvv/base/poly-selftest-1.c new file mode 100644 index 00000000000..0f128ac26b2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/poly-selftest-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O0 -fself-test=$srcdir/selftests --param=riscv-autovec-preference=fixed-vlmax -S" } */ + +/* Verify that -fself-test does not fail on a non empty source. */ + +int i; void bar(); void foo() +{ + while (i--) + bar(); +} + +/* { dg-regexp {^-fself-test: [0-9]+ pass\(es\) in [.0-9]+ seconds$|.*: note: self-tests are not enabled in this build$} } */