From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id EC3EB3858D33 for ; Tue, 7 Feb 2023 13:38:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC3EB3858D33 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-out2.suse.de (Postfix) with ESMTPS id C9207202B8 for ; Tue, 7 Feb 2023 13:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1675777108; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=vKtBYytqNTqDDHED7mA1Qdl2BQWLbcCwCOoVxjvozac=; b=jYMoJI1zY9rCGNjobu6I5IsQCeRli3MT5FANvr3DgblmRje6iLfybLMSh7yiqg+QmMs5JB zkzkMkGGlztsmKAvLWBPZrp0S4hz38caly5RvwoBUVpEkq3IWsED201tlTgeMlDMyQtUuA 7cQflP9dW9XjhcraYzJg99mG4ro7/jY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1675777108; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=vKtBYytqNTqDDHED7mA1Qdl2BQWLbcCwCOoVxjvozac=; b=Cg+99hOGeXZNDupT/MGozCgRh7U4w0CCY5k25tisT3trOQp9S4duGRS756utYLIfeLBkit CTF/gKuDHcdsdKAA== 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 B735D139ED for ; Tue, 7 Feb 2023 13:38:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fGOwK1RU4mPmdgAAMHmgww (envelope-from ) for ; Tue, 07 Feb 2023 13:38:28 +0000 Date: Tue, 7 Feb 2023 14:38:28 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/26854 - compile-time hog in SSA forwprop MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20230207133828.B735D139ED@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 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 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 following addresses tree forward propagate : 12.41 ( 9%) seen with the compile.i testcase of this PR which points at the has_use_on_stmt function which, for SSA names with many uses is slow. The solution is to instead of immediate uses, look at stmt operands to identify whether a name has a use on a stmt. That improves SSA forwprop to tree forward propagate : 1.30 ( 0%) for this testcase. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/26854 * gimple-fold.cc (has_use_on_stmt): Look at stmt operands instead of immediate uses. --- gcc/gimple-fold.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 379d2e930ea..935e8006413 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -5767,15 +5767,17 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) } -/* Return true whether NAME has a use on STMT. */ +/* Return true whether NAME has a use on STMT. Note this can return + false even though there's a use on STMT if SSA operands are not + up-to-date. */ static bool has_use_on_stmt (tree name, gimple *stmt) { - imm_use_iterator iter; - use_operand_p use_p; - FOR_EACH_IMM_USE_FAST (use_p, iter, name) - if (USE_STMT (use_p) == stmt) + ssa_op_iter iter; + tree op; + FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE) + if (op == name) return true; return false; } -- 2.35.3