From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 2E4813858410 for ; Fri, 17 Dec 2021 10:54:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E4813858410 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AA3D31435; Fri, 17 Dec 2021 02:54:42 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 106E63F5A1; Fri, 17 Dec 2021 02:54:41 -0800 (PST) From: Richard Sandiford To: Tamar Christina Mail-Followup-To: Tamar Christina , gcc-patches@gcc.gnu.org, nd@arm.com, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org, nd@arm.com Subject: Re: [PATCH]middle-end slp: check that the operation we're combing is a boolean operation [PR103741] References: Date: Fri, 17 Dec 2021 10:54:40 +0000 In-Reply-To: (Tamar Christina's message of "Fri, 17 Dec 2021 10:04:22 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 17 Dec 2021 10:54:44 -0000 Tamar Christina writes: > Hi All, > > It seems I forgot to check that the operation we're combing when masking the > predicated together are actually predicates types. > > Without it we end up accidentally trying to combine a value and a mask. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > PR tree-optimization/103741 > * tree-vect-stmts.c (vectorizable_operation): Check for boolean. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/103741 > * gcc.target/aarch64/pr103741.c: New test. > > --- inline copy of patch -- > diff --git a/gcc/testsuite/gcc.target/aarch64/pr103741.c b/gcc/testsuite/gcc.target/aarch64/pr103741.c > new file mode 100644 > index 0000000000000000000000000000000000000000..ef3ae66ebe5e5a44e7bea7be22b6378bc23cc538 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/pr103741.c > @@ -0,0 +1,26 @@ > +/* { dg-do compile } */ > +/* { dg-additional-options "-march=armv8-a+sve -O1" } */ > + > +long int m, n; > + > +int > +qux (int z) > +{ > + return 4 >> z ? z : 0; > +} > + > +int > +bar (long int y) > +{ > + return y ? 3 : 2; > +} > + > +__attribute__ ((simd)) int > +foo (int x) > +{ > + long int a = x & m; > + int b = bar (x) / n; > + > + return qux (b) == a; > +} > + > diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c > index 8c427174b37e6c03c2f914c90332bcc4eac54130..ad90cdb0473a337207d6ba54c1dd0a2ecc50ab8d 100644 > --- a/gcc/tree-vect-stmts.c > +++ b/gcc/tree-vect-stmts.c > @@ -6361,7 +6361,9 @@ vectorizable_operation (vec_info *vinfo, > /* When combining two masks check if either of them is elsewhere > combined with a loop mask, if that's the case we can mark that the > new combined mask doesn't need to be combined with a loop mask. */ > - if (masked_loop_p && code == BIT_AND_EXPR) > + if (masked_loop_p > + && code == BIT_AND_EXPR > + && VECTOR_BOOLEAN_TYPE_P (vectype)) > { > if (loop_vinfo->scalar_cond_masked_set.contains ({ op0, > ncopies})) Ah, so the reason that scalar_cond_masked_set.contains is not robust against non-boolean op0 (despite looking like it might be) is that we previously entered: cmp = X != 0 into the set as . Then looking up X implicitly becomes too. So yeah, the patch is OK, thanks. Richard