From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 72D493857B98 for ; Fri, 11 Aug 2023 12:16:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72D493857B98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A611821869; Fri, 11 Aug 2023 12:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691756194; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8SaVfIGzQwgBzn2wAYM4uG4ZQ5U+LEsezaaUiy8cxXo=; b=RjQ63fqkTkcgRpE0k8xyrQGC76cpp40IOEcnBddUnolzoebL/IYo8fRBduOR1b+oLaYrQK ETouf8Vl8r3Dv3krgRMBncmHT8PYatlJXol1oqknb46NgGUZqYlDvplUJ+YRfQ6Qc4gTAz m0LBsq5IZ3hhSBV22VMWe4Mrelmf6xY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691756194; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8SaVfIGzQwgBzn2wAYM4uG4ZQ5U+LEsezaaUiy8cxXo=; b=J7c5RM8OSQ7o9zBvyc0vFuyicJP/3nNCrjAaBaVlChdmdVmVWnG5kdKpgKohGkXKIfE2UQ +cp+Yl7gXCVmjQDA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 9734D2C142; Fri, 11 Aug 2023 12:16:34 +0000 (UTC) Date: Fri, 11 Aug 2023 12:16:34 +0000 (UTC) From: Richard Biener To: Juzhe-Zhong cc: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Re: [PATCH] VECT: Fix ICE on MASK_LEN_{LOAD,STORE} when no LEN recorded[PR110989] In-Reply-To: <20230811114919.2556172-1-juzhe.zhong@rivai.ai> Message-ID: References: <20230811114919.2556172-1-juzhe.zhong@rivai.ai> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,SPF_HELO_NONE,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 List-Id: On Fri, 11 Aug 2023, Juzhe-Zhong wrote: > This patch fixes bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110989 > > 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. Looks reasonable. Note there is size_int (...) you could use to shorten the code. Thanks, Richard. > 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/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c | 11 +++++++++++ > gcc/tree-vect-stmts.cc | 7 ++----- > 2 files changed, 13 insertions(+), 5 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..e0e2083d022 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -9126,9 +9126,8 @@ vectorizable_store (vec_info *vinfo, > { > /* 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, > + = build_int_cst (sizetype, > TYPE_VECTOR_SUBPARTS (vectype)); > } > if (!final_mask) > @@ -10713,10 +10712,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, > + = build_int_cst (sizetype, > TYPE_VECTOR_SUBPARTS (vectype)); > } > if (!final_mask) > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)