From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 6EFD73858D1E for ; Mon, 26 Jun 2023 11:18:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EFD73858D1E 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-out2.suse.de (Postfix) with ESMTP id 9C59D1F898; Mon, 26 Jun 2023 11:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687778294; 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=/WbzVwUzp52G2kOwjJUjLfRnoCyZtiW5d8DbYkkFuZ0=; b=zQC3e9Bn7WkJKBZROi7MDrskMm2zVl4r5yWAMNTvpRZAu9XzgO3Bmu3FONOElFAkMKBpDs 23cjWQYZXcMfFy9JF9lw5OFzCFYxvwMLkwe0zLUgfGKB4fZbEloNk/agFdKD7rvZQdR7Vq zQ8l5F0n0STwXuYJfKUZYcjLm/HA0P8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687778294; 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=/WbzVwUzp52G2kOwjJUjLfRnoCyZtiW5d8DbYkkFuZ0=; b=0OsmEAs/qinUOKbkIHzsJOum58gdz2XJNdAkp9KjRDlfpDgecbbZMLmQZnEdB15n5n282i 26ANrYvASikDw9Ag== 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 88C292C141; Mon, 26 Jun 2023 11:18:14 +0000 (UTC) Date: Mon, 26 Jun 2023 11:18:14 +0000 (UTC) From: Richard Biener To: Ju-Zhe Zhong cc: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Re: [PATCH V2] SCCVN: Add LEN_MASK_STORE and fix LEN_STORE In-Reply-To: <20230626093846.3006718-1-juzhe.zhong@rivai.ai> Message-ID: References: <20230626093846.3006718-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=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: On Mon, 26 Jun 2023, juzhe.zhong@rivai.ai wrote: > From: Ju-Zhe Zhong > > Hi, Richi. It seems that we use nunits which is len + bias to iterate then we can > simplify the codes. > > Also, I fixed behavior of len_store, > > Before this patch: > (len - bias) * BITS_PER_UNIT > After this patch: > (len + bias) * BITS_PER_UNIT > > gcc/ChangeLog: > > * tree-ssa-sccvn.cc (vn_reference_lookup_3): Add LEN_MAS_STORE and fix LEN_STORE. > > --- > gcc/tree-ssa-sccvn.cc | 19 +++++++++++++++++-- > 1 file changed, 17 insertions(+), 2 deletions(-) > > diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc > index 11061a374a2..228ec117ff3 100644 > --- a/gcc/tree-ssa-sccvn.cc > +++ b/gcc/tree-ssa-sccvn.cc > @@ -3304,6 +3304,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, > if (!tree_fits_uhwi_p (len) || !tree_fits_shwi_p (bias)) > return (void *)-1; > break; > + case IFN_LEN_MASK_STORE: > + len = gimple_call_arg (call, 2); > + bias = gimple_call_arg (call, 5); > + if (!tree_fits_uhwi_p (len) || !tree_fits_shwi_p (bias)) > + return (void *)-1; > + mask = gimple_call_arg (call, internal_fn_mask_index (fn)); > + mask = vn_valueize (mask); > + if (TREE_CODE (mask) != VECTOR_CST) > + return (void *)-1; > + break; > default: > return (void *)-1; > } > @@ -3344,6 +3354,11 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, > tree vectype = TREE_TYPE (def_rhs); > unsigned HOST_WIDE_INT elsz > = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (vectype))); > + poly_uint64 nunits; > + if (len) > + nunits = tree_to_uhwi (len) + tree_to_shwi (bias); > + else > + nunits = TYPE_VECTOR_SUBPARTS (vectype); Are the _LEN ifns accessible via intrinsics as well? If so I think we should use MIN (nunits, len + bias) here as otherwise we risk out-of bound accesses. Otherwise looks good to me. Thanks, Richard. > if (mask) > { > HOST_WIDE_INT start = 0, length = 0; > @@ -3373,7 +3388,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, > length += elsz; > mask_idx++; > } > - while (known_lt (mask_idx, TYPE_VECTOR_SUBPARTS (vectype))); > + while (known_lt (mask_idx, nunits)); > if (length != 0) > { > pd.rhs_off = start; > @@ -3389,7 +3404,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, > { > pd.offset = offset2i; > pd.size = (tree_to_uhwi (len) > - + -tree_to_shwi (bias)) * BITS_PER_UNIT; > + + tree_to_shwi (bias)) * BITS_PER_UNIT; > if (BYTES_BIG_ENDIAN) > pd.rhs_off = pd.size - tree_to_uhwi (TYPE_SIZE (vectype)); > else > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)