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 5C9763858CDA for ; Tue, 10 Jan 2023 09:46:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9763858CDA 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 269733833C; Tue, 10 Jan 2023 09:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1673343974; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=8hBSrkN2XAp+1mB9K+hkcVxvPdO2m0c/glyPgKc4sV8=; b=zHugDDg/qzQZI1PTR1A5M70jKEQQFD14erMizr5E4QXwJSZ5vLOo4mpfob+wrKdGH7tIUW VcF/k0gTOrrnFW8F8HSeevtWcZ8IXbtNDSOf0sqHxMidUS5E/jf0vGxfzE1itSEcDUV3lh mcZrVO/9047xHVHlQaL2nksyrETA9/0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1673343974; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=8hBSrkN2XAp+1mB9K+hkcVxvPdO2m0c/glyPgKc4sV8=; b=vYflUFC+mHZf45VCoEBGCQ/Dnx1/HrvN+TDd3Kc4BESAKWz3Ytc3gCDHZae6M8R/sUcdWb 9KTn6mgKP4nBsrDw== 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 0E81A1358A; Tue, 10 Jan 2023 09:46:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RSdXAuYzvWMxPgAAMHmgww (envelope-from ); Tue, 10 Jan 2023 09:46:14 +0000 Date: Tue, 10 Jan 2023 10:46:13 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: richard.sandiford@arm.com Subject: [PATCH] tree-optimization/108314 - avoid BIT_NOT optimization for extract-last MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20230110094614.0E81A1358A@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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: The extract-last reduction internal function expects the then and else clause as vector and scalar and thus we cannot perform optimization of the inversion of the condition by swapping the then/else clauses. Bootstrap and regtest running on x86_64-unknown-linux-gnu, OK? Thanks, Richard. PR tree-optimization/108314 * tree-vect-stmts.cc (vectorizable_condition): Do not perform BIT_NOT_EXPR optimization for EXTRACT_LAST_REDUCTION. * gcc.dg/vect/pr108314.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr108314.c | 16 ++++++++++++++++ gcc/tree-vect-stmts.cc | 13 +++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr108314.c diff --git a/gcc/testsuite/gcc.dg/vect/pr108314.c b/gcc/testsuite/gcc.dg/vect/pr108314.c new file mode 100644 index 00000000000..07260e06915 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr108314.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv9-a" { target aarch64-*-* } } */ + +int x, y, z; + +void f(void) +{ + int t = 4; + for (; x; x++) + { + if (y) + continue; + t = 0; + } + z = t; +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 6ddd41fb473..eb4ca1f184e 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -10677,7 +10677,8 @@ vectorizable_condition (vec_info *vinfo, vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); if (bitop2 == NOP_EXPR) vec_compare = new_temp; - else if (bitop2 == BIT_NOT_EXPR) + else if (bitop2 == BIT_NOT_EXPR + && reduction_type != EXTRACT_LAST_REDUCTION) { /* Instead of doing ~x ? y : z do x ? z : y. */ vec_compare = new_temp; @@ -10686,9 +10687,13 @@ vectorizable_condition (vec_info *vinfo, else { vec_compare = make_ssa_name (vec_cmp_type); - new_stmt - = gimple_build_assign (vec_compare, bitop2, - vec_cond_lhs, new_temp); + if (bitop2 == BIT_NOT_EXPR) + new_stmt + = gimple_build_assign (vec_compare, bitop2, new_temp); + else + new_stmt + = gimple_build_assign (vec_compare, bitop2, + vec_cond_lhs, new_temp); vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); } -- 2.35.3