From patchwork Thu Jan 9 12:59:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 104406 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 1B8B93858C41 for ; Thu, 9 Jan 2025 13:05:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B8B93858C41 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xSxntyt0; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TOY3TJ0Q; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xSxntyt0; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TOY3TJ0Q 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 [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id F30F03858424 for ; Thu, 9 Jan 2025 12:59:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F30F03858424 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 F30F03858424 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736427560; cv=none; b=s4Ec35a81XKpZYeWdB0PEAFW4yKvnr4Yz3vqvMGtSQqmo8mOeiJjqjqgsT1YUGXNCCj9kQj+Uam3kUONRoe34c+Af8Ompe9TgNSDQthET+6EL3bf7wpWCwtB7ltM1q18vA36Fo42QKTDSDFnhX4rCWlfn1wvPkOWkBVvL2JWvfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736427560; c=relaxed/simple; bh=ifqOXxYy1I1RITMQqCPkEhe00Myu6w4qADg4UFI3sww=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=V82z/HKgZZ1VWRp2/JH+nhTi95MF/aIWGbz+F+AgoVtiU0ciSCoawoPnsPRy6VvWl1448SOM8N/3aQ+8GJOOY9CW0+BCyvdMol1HRaV3BKW/5IytZXV3ZzYv6P1fQx6s93ID7E9ZoZbtUx5F2enZq5W+ROts3rOzNdnRe5VMbzk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F30F03858424 Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (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 EF3AD1F394; Thu, 9 Jan 2025 12:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1736427559; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=GrurDovJPcywTnpg5JZx9uclCMbOIYgCq+3+exzXqnQ=; b=xSxntyt0jLXjPZmqIlD25DAciVZH53s7Y848TVX0etIoEEtC7EhvYK6og/DbH98dNWwEZN 6iLo9KjvI3YPfZX/x8VhTxFO+doaFLBhCAcia9D+vmrhmN9FTp2f+gKCxO76aef1a/Brja tSdqihGCfVV3WehlKLBs5LRxyJdo1rs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1736427559; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=GrurDovJPcywTnpg5JZx9uclCMbOIYgCq+3+exzXqnQ=; b=TOY3TJ0QjzXd5vUij6uU54vNC4x6YWI2HYJ9u/ZHJDmznKCUewyg8KxfzrzE3IohFHjBsm zWnGTRw+CBGyA/Dg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1736427559; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=GrurDovJPcywTnpg5JZx9uclCMbOIYgCq+3+exzXqnQ=; b=xSxntyt0jLXjPZmqIlD25DAciVZH53s7Y848TVX0etIoEEtC7EhvYK6og/DbH98dNWwEZN 6iLo9KjvI3YPfZX/x8VhTxFO+doaFLBhCAcia9D+vmrhmN9FTp2f+gKCxO76aef1a/Brja tSdqihGCfVV3WehlKLBs5LRxyJdo1rs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1736427559; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=GrurDovJPcywTnpg5JZx9uclCMbOIYgCq+3+exzXqnQ=; b=TOY3TJ0QjzXd5vUij6uU54vNC4x6YWI2HYJ9u/ZHJDmznKCUewyg8KxfzrzE3IohFHjBsm zWnGTRw+CBGyA/Dg== Date: Thu, 9 Jan 2025 13:59:18 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: RISC-V CI Subject: [PATCH] Fix SLP scalar costing with stmts also used in externals MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-1.51 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.71)[-0.715]; NEURAL_HAM_SHORT(-0.20)[-0.979]; MIME_GOOD(-0.10)[text/plain]; MISSING_XM_UA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[] X-Spam-Score: -1.51 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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 Message-Id: <20250109130551.1B8B93858C41@sourceware.org> When we have the situation of an external SLP node that is permuted the scalar stmts recorded in the permute node do not mean the scalar computation can be removed. We are removing those stmts from the vectorized_scalar_stmts for this reason but we fail to check this set when we cost scalar stmts. The following fixes this. This shows in PR115777 when we avoid vectorizing the load, but on it's own doesn't help the PR yet. Bootstrap and regtest running on x86_64-unknown-linux-gnu. PR tree-optimization/115777 * tree-vect-slp.cc (vect_bb_slp_scalar_cost): Do not cost a scalar stmt that needs to be preserved. --- gcc/tree-vect-slp.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 337506419d9..152ca433b0e 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -8687,7 +8687,12 @@ vect_bb_slp_scalar_cost (vec_info *vinfo, ssa_op_iter op_iter; def_operand_p def_p; - if (!stmt_info || (*life)[i]) + if (!stmt_info + || (*life)[i] + /* Defs also used in external nodes are not in the + vectorized_scalar_stmts set as they need to be preserved. + Honor that. */ + || !vectorized_scalar_stmts.contains (stmt_info)) continue; stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info);