From patchwork Tue Oct 29 10:17:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 99758 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D1703858433 for ; Tue, 29 Oct 2024 10:18:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 8E02D3858C60 for ; Tue, 29 Oct 2024 10:17:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E02D3858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8E02D3858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730197085; cv=none; b=CjtMx8CMFUQ0ne7b7nAoMdohoaRySccz+EMAs1YZFEOoda3NZ3/eTJkOeWx1zMiFqmgaTlin6rfYYhVaTHMdcQvT1iEOrH8uXmW6RJgMwrJ0CI5KEvEdwsTjCNsM6dJBz2iFgidFF3XH+JLPOm+D6cYFH6agdmmCMjJUdGHNXLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730197085; c=relaxed/simple; bh=A3xIL3qMJZpcZ+WVI42nsl9kOwFgmpa50sK1XjFxxiE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=DG10OhVWvvvW7G1i56Y0FmHC+G7T61XLT6wf3P7GXubgjwNns/n6sM6yj7BYyjVJ9xkyQh7fpjMFpPiO/9jlj662l/bR1V0u2/gmJGY2MePG7ovC4k76cTp2d6QfnmeBEcPPZMg+NK4GifBJUJ9mHVLQDGhEUHeyPWH1b/2ECT8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 923CD1F769 for ; Tue, 29 Oct 2024 10:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730197077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ia9GMXUYdkylt1kkp0IUpfxuNXb/5+3FwDW6tIF/enY=; b=X6tVzNPeGTmkwiUUaXcr5TkU+7RdpBKblAeDis17O1rfn2SFqZcoLy8cbP7RUtapO9CkVd wkLXcFJr5s4+f0gnzFs1Hg4KARFZ0wF+4ZeEHYRtQ+1THSymDaQV/UDvg3PMklvve+6hrh 7OTQzV/86suJ5DSa8ZXtVIYg9xOIBkg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730197077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ia9GMXUYdkylt1kkp0IUpfxuNXb/5+3FwDW6tIF/enY=; b=JAgt9fswt/B7BaqL6GYQUWNTaJn28G3coQUF9PBQrXhxDurdeJC9us55nLz7IhXah8hDVR LVxg6jeIAbZ/7XCQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730197077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ia9GMXUYdkylt1kkp0IUpfxuNXb/5+3FwDW6tIF/enY=; b=X6tVzNPeGTmkwiUUaXcr5TkU+7RdpBKblAeDis17O1rfn2SFqZcoLy8cbP7RUtapO9CkVd wkLXcFJr5s4+f0gnzFs1Hg4KARFZ0wF+4ZeEHYRtQ+1THSymDaQV/UDvg3PMklvve+6hrh 7OTQzV/86suJ5DSa8ZXtVIYg9xOIBkg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730197077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ia9GMXUYdkylt1kkp0IUpfxuNXb/5+3FwDW6tIF/enY=; b=JAgt9fswt/B7BaqL6GYQUWNTaJn28G3coQUF9PBQrXhxDurdeJC9us55nLz7IhXah8hDVR LVxg6jeIAbZ/7XCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7714F139A2 for ; Tue, 29 Oct 2024 10:17:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 3oxzG1W2IGfNLwAAD6G6ig (envelope-from ) for ; Tue, 29 Oct 2024 10:17:57 +0000 Date: Tue, 29 Oct 2024 11:17:42 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] Remove dead code in vectorizer pattern recog MIME-Version: 1.0 Message-Id: <20241029101757.7714F139A2@imap1.dmz-prg2.suse.org> X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:mid] X-Spam-Score: -4.30 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org The following removes the code path in vect_recog_mask_conversion_pattern dealing with comparisons in COND_EXPRs. That can no longer happen. * tree-vect-patterns.cc (vect_recog_mask_conversion_pattern): Remove COMPARISON_CLASS_P rhs1 of COND_EXPR case and assert it doesn't happen. --- gcc/tree-vect-patterns.cc | 99 +-------------------------------------- 1 file changed, 2 insertions(+), 97 deletions(-) diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index a6d246f570c..46f439fb8a3 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -6240,8 +6240,6 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo, tree lhs = NULL_TREE, rhs1, rhs2, tmp, rhs1_type, rhs2_type; tree vectype1, vectype2; stmt_vec_info pattern_stmt_info; - tree rhs1_op0 = NULL_TREE, rhs1_op1 = NULL_TREE; - tree rhs1_op0_type = NULL_TREE, rhs1_op1_type = NULL_TREE; /* Check for MASK_LOAD and MASK_STORE as well as COND_OP calls requiring mask conversion. */ @@ -6331,60 +6329,13 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo, { vectype1 = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs)); + gcc_assert (! COMPARISON_CLASS_P (rhs1)); if (TREE_CODE (rhs1) == SSA_NAME) { rhs1_type = integer_type_for_mask (rhs1, vinfo); if (!rhs1_type) return NULL; } - else if (COMPARISON_CLASS_P (rhs1)) - { - /* Check whether we're comparing scalar booleans and (if so) - whether a better mask type exists than the mask associated - with boolean-sized elements. This avoids unnecessary packs - and unpacks if the booleans are set from comparisons of - wider types. E.g. in: - - int x1, x2, x3, x4, y1, y1; - ... - bool b1 = (x1 == x2); - bool b2 = (x3 == x4); - ... = b1 == b2 ? y1 : y2; - - it is better for b1 and b2 to use the mask type associated - with int elements rather bool (byte) elements. */ - rhs1_op0 = TREE_OPERAND (rhs1, 0); - rhs1_op1 = TREE_OPERAND (rhs1, 1); - if (!rhs1_op0 || !rhs1_op1) - return NULL; - rhs1_op0_type = integer_type_for_mask (rhs1_op0, vinfo); - rhs1_op1_type = integer_type_for_mask (rhs1_op1, vinfo); - - if (!rhs1_op0_type) - rhs1_type = TREE_TYPE (rhs1_op0); - else if (!rhs1_op1_type) - rhs1_type = TREE_TYPE (rhs1_op1); - else if (TYPE_PRECISION (rhs1_op0_type) - != TYPE_PRECISION (rhs1_op1_type)) - { - int tmp0 = (int) TYPE_PRECISION (rhs1_op0_type) - - (int) TYPE_PRECISION (TREE_TYPE (lhs)); - int tmp1 = (int) TYPE_PRECISION (rhs1_op1_type) - - (int) TYPE_PRECISION (TREE_TYPE (lhs)); - if ((tmp0 > 0 && tmp1 > 0) || (tmp0 < 0 && tmp1 < 0)) - { - if (abs (tmp0) > abs (tmp1)) - rhs1_type = rhs1_op1_type; - else - rhs1_type = rhs1_op0_type; - } - else - rhs1_type = build_nonstandard_integer_type - (TYPE_PRECISION (TREE_TYPE (lhs)), 1); - } - else - rhs1_type = rhs1_op0_type; - } else return NULL; @@ -6400,55 +6351,9 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo, its vector type) and behave as though the comparison was an SSA name from the outset. */ if (known_eq (TYPE_VECTOR_SUBPARTS (vectype1), - TYPE_VECTOR_SUBPARTS (vectype2)) - && !rhs1_op0_type - && !rhs1_op1_type) + TYPE_VECTOR_SUBPARTS (vectype2))) return NULL; - /* If rhs1 is invariant and we can promote it leave the COND_EXPR - in place, we can handle it in vectorizable_condition. This avoids - unnecessary promotion stmts and increased vectorization factor. */ - if (COMPARISON_CLASS_P (rhs1) - && INTEGRAL_TYPE_P (rhs1_type) - && known_le (TYPE_VECTOR_SUBPARTS (vectype1), - TYPE_VECTOR_SUBPARTS (vectype2))) - { - enum vect_def_type dt; - if (vect_is_simple_use (TREE_OPERAND (rhs1, 0), vinfo, &dt) - && dt == vect_external_def - && vect_is_simple_use (TREE_OPERAND (rhs1, 1), vinfo, &dt) - && (dt == vect_external_def - || dt == vect_constant_def)) - { - tree wide_scalar_type = build_nonstandard_integer_type - (vector_element_bits (vectype1), TYPE_UNSIGNED (rhs1_type)); - tree vectype3 = get_vectype_for_scalar_type (vinfo, - wide_scalar_type); - if (expand_vec_cond_expr_p (vectype1, vectype3, TREE_CODE (rhs1))) - return NULL; - } - } - - /* If rhs1 is a comparison we need to move it into a - separate statement. */ - if (TREE_CODE (rhs1) != SSA_NAME) - { - tmp = vect_recog_temp_ssa_var (TREE_TYPE (rhs1), NULL); - if (rhs1_op0_type - && TYPE_PRECISION (rhs1_op0_type) != TYPE_PRECISION (rhs1_type)) - rhs1_op0 = build_mask_conversion (vinfo, rhs1_op0, - vectype2, stmt_vinfo); - if (rhs1_op1_type - && TYPE_PRECISION (rhs1_op1_type) != TYPE_PRECISION (rhs1_type)) - rhs1_op1 = build_mask_conversion (vinfo, rhs1_op1, - vectype2, stmt_vinfo); - pattern_stmt = gimple_build_assign (tmp, TREE_CODE (rhs1), - rhs1_op0, rhs1_op1); - rhs1 = tmp; - append_pattern_def_seq (vinfo, stmt_vinfo, pattern_stmt, vectype2, - rhs1_type); - } - if (maybe_ne (TYPE_VECTOR_SUBPARTS (vectype1), TYPE_VECTOR_SUBPARTS (vectype2))) tmp = build_mask_conversion (vinfo, rhs1, vectype1, stmt_vinfo);