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 24EAF3858415 for ; Wed, 9 Mar 2022 14:21:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 24EAF3858415 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 B0F131F384; Wed, 9 Mar 2022 14:21:53 +0000 (UTC) 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 97CCD13D79; Wed, 9 Mar 2022 14:21:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yz2UIwG4KGK2PAAAMHmgww (envelope-from ); Wed, 09 Mar 2022 14:21:53 +0000 Date: Wed, 9 Mar 2022 15:21:53 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek Subject: [PATCH] Restore INDIRECT_REF asm operand heuristic with MEM_REF MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220309142153.97CCD13D79@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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Mar 2022 14:21:56 -0000 As noticed we are looking for INDIRECT_REF with allows_mem to avoid a copy since then we're sure the operand is in memory (assuming *& is folded). But INDIRECT_REFs are no longer a thing, the following replaces the check with a check for a MEM_REF with a non-ADDR_EXPR operand. This should fix the regression part without fully exploring all possibilities around tcc_reference operands. I've placed an assert that we do not see an INDIRECT_REF here. While we gimplify asm operands we never do any checking on its IL afterwards. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. OK if that succeeds? Thanks, Richard. 2022-03-09 Richard Biener * cfgexpand.c (expand_gimple_asm): Special-case MEM_REF with non-decl operand, avoiding a copy. --- gcc/cfgexpand.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index 4f99f040450..d3cc77d2ca9 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -3290,7 +3290,10 @@ expand_asm_stmt (gasm *stmt) generating_concat_p = 0; - if ((TREE_CODE (val) == INDIRECT_REF && allows_mem) + gcc_assert (TREE_CODE (val) != INDIRECT_REF); + if (((TREE_CODE (val) == MEM_REF + && TREE_CODE (TREE_OPERAND (val, 0)) != ADDR_EXPR) + && allows_mem) || (DECL_P (val) && (allows_mem || REG_P (DECL_RTL (val))) && ! (REG_P (DECL_RTL (val)) -- 2.34.1