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 CAC923858C50 for ; Thu, 7 Jul 2022 07:47:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CAC923858C50 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 80244220E4; Thu, 7 Jul 2022 07:47:17 +0000 (UTC) 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 771202C141; Thu, 7 Jul 2022 07:47:17 +0000 (UTC) Date: Thu, 7 Jul 2022 07:47:16 +0000 (UTC) From: Richard Biener To: Tamar Christina cc: "gcc-patches@gcc.gnu.org" , nd Subject: RE: [PATCH]middle-end: don't lower past veclower [PR106063] In-Reply-To: Message-ID: References: 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, 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 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: , X-List-Received-Date: Thu, 07 Jul 2022 07:47:20 -0000 On Thu, 7 Jul 2022, Tamar Christina wrote: > > -----Original Message----- > > From: Richard Biener > > Sent: Thursday, July 7, 2022 8:19 AM > > To: Tamar Christina > > Cc: gcc-patches@gcc.gnu.org; nd > > Subject: Re: [PATCH]middle-end: don't lower past veclower [PR106063] > > > > On Tue, 5 Jul 2022, Tamar Christina wrote: > > > > > Hi All, > > > > > > My previous patch can cause a problem if the pattern matches after > > > veclower as it may replace the construct with a vector sequence which > > > the target may not directly support. > > > > > > As such don't perform the rewriting if after veclower. > > > > Note that when doing the rewriting before veclower to a variant not > > supported by the target can cause veclower to generate absymal code. In > > some cases we are very careful and try to at least preserve code supported > > by the target over transforming that into a variant not supported. > > > > That said, a better fix would be to check whether the target can perform the > > new comparison. Before veclower it would be OK to do the transform > > nevertheless in case it cannot do the original transform. > > This last statement is somewhat confusing. Did you want me to change it such that > before veclower the rewrite is always done and after veclowering only if the target > supports it? > > Or did you want me to never do the rewrite if the target doesn't support it? I meant before veclower you can do the rewrite if either the rewriting result is supported by the target OR if the original expression is _not_ supported by the target. The latter case might be not too important to worry doing (it would still canonicalize for those targets then). After veclower you can only rewrite under the former condition. Richard. > Thanks, > Tamar > > > > > Richard. > > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu > > > and no issues. > > > > > > Ok for master? and backport to GCC 12? > > > > > > Thanks, > > > Tamar > > > > > > > > > gcc/ChangeLog: > > > > > > PR tree-optimization/106063 > > > * match.pd: Do not apply pattern after veclower. > > > > > > gcc/testsuite/ChangeLog: > > > > > > PR tree-optimization/106063 > > > * gcc.dg/pr106063.c: New test. > > > > > > --- inline copy of patch -- > > > diff --git a/gcc/match.pd b/gcc/match.pd index > > > > > 40c09bedadb89dabb6622559a8f69df5384e61fd..ba161892a98756c0278dc40fc > > 377 > > > d7d0deaacbcf 100644 > > > --- a/gcc/match.pd > > > +++ b/gcc/match.pd > > > @@ -6040,7 +6040,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > > > (simplify > > > (cmp (bit_and:c@2 @0 cst@1) integer_zerop) > > > (with { tree csts = bitmask_inv_cst_vector_p (@1); } > > > - (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2))) > > > + (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)) > > > + && optimize_vectors_before_lowering_p ()) > > > (if (TYPE_UNSIGNED (TREE_TYPE (@1))) > > > (icmp @0 { csts; }) > > > (with { tree utype = unsigned_type_for (TREE_TYPE (@1)); } > > > diff --git a/gcc/testsuite/gcc.dg/pr106063.c > > > b/gcc/testsuite/gcc.dg/pr106063.c new file mode 100644 index > > > > > 0000000000000000000000000000000000000000..b23596724f6bb98c53af2dce77 > > d3 > > > 1509bab10378 > > > --- /dev/null > > > +++ b/gcc/testsuite/gcc.dg/pr106063.c > > > @@ -0,0 +1,9 @@ > > > +/* { dg-do compile } */ > > > +/* { dg-options "-O2 -fno-tree-forwprop --disable-tree-evrp" } */ > > > +typedef __int128 __attribute__((__vector_size__ (16))) V; > > > + > > > +V > > > +foo (V v) > > > +{ > > > + return (v & (V){15}) == v; > > > +} > > > > > > > > > > > > > > > > > > > -- > > Richard Biener > > SUSE Software Solutions Germany GmbH, Frankenstra > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstra