From patchwork Fri Aug 11 13:55:42 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: 1820289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RMlgn5KSyz1yf7 for ; Fri, 11 Aug 2023 23:56:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BFE733857707 for ; Fri, 11 Aug 2023 13:56:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by sourceware.org (Postfix) with ESMTPS id 079013858D20 for ; Fri, 11 Aug 2023 13:55:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 079013858D20 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: bizesmtp71t1691762145tdv7nie4 Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 11 Aug 2023 21:55:43 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: LE7C6P2vL8Sf+Hd4LCtQIADQjEKwL9lxHGigmRPbyTSMqxkoRhW/AJC5a2Xqt ZcCT2Er5Eo4wMv48VXjsZKcuHSr26UmKsODU+jWQ2DlCnvophLc26AGBHzZkZzNgKmu7xUL 1DV9TtUhEzuZVLrsoIwLMDzNQbDua0LzSZDPjVFXcZk/37NdY+3tWgBsyzyiv+A0YKJvP6I u7aYC6E57CfZntO6sqZbvQ5BLEcCellUdDQpl1Vt/ivCtkBxQ04X8QuACzNUg/LBz6YOGUS 1E8uz49dG4ktfImWTdOa9/Bho8krySnvCPEq8NJd0tf38wLyGn4dQJZetGze2A2Z3fAdGkJ OWy+Mzuc0BRu87h/g+ywxZSEWL1AEREg0Q4jAvJe21pmQ6FMnFnYPYu7KxTlo5Qd9LYVFop HzPh8eXcZzo= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 14059528098273679011 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, Juzhe-Zhong Subject: [PATCH V2] VECT: Fix ICE on MASK_LEN_{LOAD, STORE} when no LEN recorded[PR110989] Date: Fri, 11 Aug 2023 21:55:42 +0800 Message-Id: <20230811135542.2823827-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=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This ICE is caused because of this situation: mask__49.21_99 = vect__17.19_96 == { 0.0, ... }; ... vect__6.24_107 = .MASK_LEN_LOAD (vectp.22_105, 32B, mask__49.21_99, POLY_INT_CST [2, 2], 0); The MASK_LEN_LOAD is using real MASK which is produced by the EQ comparison wheras the LEN is the dummy LEN which is the vectorization factor. In this situation, we didn't enter 'vect_record_loop_len' since there is no LEN loop control. Then 'LOOP_VINFO_RGROUP_IV_TYPE' is not suitable type for 'build_int_cst' used for producing LEN argument for 'MASK_LEN_LOAD', so use sizetype instead which is perfectly matching RVV length requirement. PR middle-end/110989 gcc/ChangeLog: * tree-vect-stmts.cc (vectorizable_store): Replace iv_type with sizetype. (vectorizable_load): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr110989.c: New test. --- .../gcc.target/riscv/rvv/autovec/pr110989.c | 11 +++++++++++ gcc/tree-vect-stmts.cc | 12 +++--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c new file mode 100644 index 00000000000..cf3b247e604 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=riscv-autovec-preference=scalable -Ofast" } */ + +int a, b, c; +double *d; +void e() { + double f; + for (; c; c++, d--) + f = *d ?: *(&a + c); + b = f; +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 398fbe945e5..89607a98f99 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9125,11 +9125,8 @@ vectorizable_store (vec_info *vinfo, if (!final_len) { /* Pass VF value to 'len' argument of - MASK_LEN_STORE if LOOP_LENS is invalid. */ - tree iv_type = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo); - final_len - = build_int_cst (iv_type, - TYPE_VECTOR_SUBPARTS (vectype)); + MASK_LEN_STORE if LOOP_LENS is invalid. */ + final_len = size_int (TYPE_VECTOR_SUBPARTS (vectype)); } if (!final_mask) { @@ -10713,11 +10710,8 @@ vectorizable_load (vec_info *vinfo, { /* Pass VF value to 'len' argument of MASK_LEN_LOAD if LOOP_LENS is invalid. */ - tree iv_type - = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo); final_len - = build_int_cst (iv_type, - TYPE_VECTOR_SUBPARTS (vectype)); + = size_int (TYPE_VECTOR_SUBPARTS (vectype)); } if (!final_mask) {