From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 5C958395B407 for ; Sat, 17 Sep 2022 05:03:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C958395B407 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 imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 521C8347A5; Sat, 17 Sep 2022 05:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1663390988; 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=61PWbPGJMdQqcI2hIDw7T6qmO99KNuuPhbT40RniLmc=; b=dyqPCu2nF4n1Vy8RN1sV6dtHuk0yOGLk5shCxHHqUg4HKCOEdIfA4EOX2vjV5BznkWaCUN XK9hx52vjAxiviMnXq1UwEDanQ5ECh6h9ZImY5y40W6S0ALPr26XJzmyY1TjEFywqDOKzR KP8LjNzvea5E4zy253F3ZJb3D+EsNcs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1663390988; 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=61PWbPGJMdQqcI2hIDw7T6qmO99KNuuPhbT40RniLmc=; b=rXjZO3xRncaedlAapdj/i8X2uGF3e0F8aWiFF03xEWwi26i6P4yJxjBllIfgpq6c6cnuRp ZUTnwdmE+M1r9RBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2E0B713A49; Sat, 17 Sep 2022 05:03:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SYAlCgxVJWMhaAAAMHmgww (envelope-from ); Sat, 17 Sep 2022 05:03:08 +0000 Date: Sat, 17 Sep 2022 07:03:07 +0200 (CEST) From: Richard Biener X-X-Sender: rguenther@rguenther-XPS-13-9380 To: Richard Sandiford cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] vect: Fix missed gather load opportunity In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-11.8 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 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, 16 Sep 2022, Richard Sandiford wrote: > While writing a testcase for PR106794, I noticed that we failed > to vectorise the testcase in the patch for SVE. The code that > recognises gather loads tries to optimise the point at which > the offset is calculated, to avoid unnecessary extensions or > truncations: > > /* Don't include the conversion if the target is happy with > the current offset type. */ > > But breaking only makes sense if we're at an SSA_NAME (which could > then be vectorised). We shouldn't break on a conversion embedded > in a generic expression. > > Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? OK, Thanks, Richard. > Richard > > > gcc/ > * tree-vect-data-refs.cc (vect_check_gather_scatter): Restrict > early-out optimisation to SSA_NAMEs. > > gcc/testsuite/ > * gcc.dg/vect/vect-gather-5.c: New test. > --- > gcc/testsuite/gcc.dg/vect/vect-gather-5.c | 42 +++++++++++++++++++++++ > gcc/tree-vect-data-refs.cc | 1 + > 2 files changed, 43 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/vect/vect-gather-5.c > > diff --git a/gcc/testsuite/gcc.dg/vect/vect-gather-5.c b/gcc/testsuite/gcc.dg/vect/vect-gather-5.c > new file mode 100644 > index 00000000000..8b5074bba88 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/vect-gather-5.c > @@ -0,0 +1,42 @@ > +/* { dg-do compile } */ > +/* { dg-additional-options "-O3" } */ > + > +#ifdef __aarch64__ > +#pragma GCC target "+sve" > +#endif > + > +long a[100], b[100], c[100]; > + > +void g1 () > +{ > + for (int i = 0; i < 100; i += 2) > + { > + c[i] += a[b[i]] + 1; > + c[i + 1] += a[b[i + 1]] + 2; > + } > +} > + > +long g2 () > +{ > + long res = 0; > + for (int i = 0; i < 100; i += 2) > + { > + res += a[b[i + 1]]; > + res += a[b[i]]; > + } > + return res; > +} > + > +long g3 () > +{ > + long res = 0; > + for (int i = 0; i < 100; i += 2) > + { > + res += a[b[i]]; > + res += a[b[i + 1]]; > + } > + return res; > +} > + > +/* { dg-final { scan-tree-dump-times {add new stmt[^\n]*GATHER_LOAD} 3 "vect" { target aarch64*-*-* } } } */ > +/* { dg-final { scan-tree-dump-not {add new stmt[^\n]*VEC_PERM_EXPR} "vect" { target aarch64*-*-* } } } */ > diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc > index b279a82551e..e03b50498d1 100644 > --- a/gcc/tree-vect-data-refs.cc > +++ b/gcc/tree-vect-data-refs.cc > @@ -4151,6 +4151,7 @@ vect_check_gather_scatter (stmt_vec_info stmt_info, loop_vec_info loop_vinfo, > /* Don't include the conversion if the target is happy with > the current offset type. */ > if (use_ifn_p > + && TREE_CODE (off) == SSA_NAME > && !POINTER_TYPE_P (TREE_TYPE (off)) > && vect_gather_scatter_fn_p (loop_vinfo, DR_IS_READ (dr), > masked_p, vectype, memory_type, > -- > 2.25.1 > >