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 906D23858024 for ; Thu, 10 Nov 2022 14:19:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 906D23858024 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 8180B1F9A0 for ; Thu, 10 Nov 2022 14:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668089976; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=9YK0h5Jfhk8LQDM/PiJOCkxZWBJfy0Lrod9uRUnTY8M=; b=OCKC2XQdlvpvBYkSIS/ovb5YIS7MERHyGzO7QCQtOX9N2axytf6IXzZsq2dmdz007HAmg7 LttUgYTEsQOt39iajGiQ/XJCfQ/gsAvHppTbLyqR7SAwZbf9Gi/jF/68b+kaOVYOro4cB/ 9l1vtvRzVs0+2G1/It1UD2o/W6MSBWc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668089976; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=9YK0h5Jfhk8LQDM/PiJOCkxZWBJfy0Lrod9uRUnTY8M=; b=J3VAoVgF2hQpy91KMeoD+GcsXWCXgcZF80xjuqt5zQLTrqbDEyrwJ8Ljo3o7+tqx5x1Dp4 4kBzULCW4bAVh3Cw== 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 62A821332F for ; Thu, 10 Nov 2022 14:19:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id W2LkFngIbWMHHgAAMHmgww (envelope-from ) for ; Thu, 10 Nov 2022 14:19:36 +0000 Date: Thu, 10 Nov 2022 15:19:36 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] better PHI copy propagation for forwprop MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20221110141936.62A821332F@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: We can handle _1 = PHI <_1, _2> as a copy. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/84646 * tree-ssa-forwprop.cc (pass_forwprop::execute): Improve copy propagation across PHIs. --- gcc/tree-ssa-forwprop.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index 4b693ef095c..7c7942600ef 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -3384,7 +3384,12 @@ pass_forwprop::execute (function *fun) FOR_EACH_PHI_ARG (use_p, phi, it, SSA_OP_USE) { tree use = USE_FROM_PTR (use_p); - if (! first) + if (use == res) + /* The PHI result can also appear on a backedge, if so + we can ignore this case for the purpose of determining + the singular value. */ + ; + else if (! first) first = use; else if (! operand_equal_p (first, use, 0)) { -- 2.35.3