From patchwork Wed Oct 13 12:19:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 46171 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 9BF213858413 for ; Wed, 13 Oct 2021 12:20:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BF213858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634127608; bh=XaDlMK5C6NClvhYpVNeqJ1x6PSLbyVYrPAy/hEpfyxs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=JPiYpoJmFOt8SSSCVjd7PdXm3VwO4y9ILxxFo587IfotdWGjI7fDlmLgNH6YsNsx2 /vpCmfKz+0vNgqe9rdpX7NOVdJgHb9ntnLVaNXxSvYT+/gQgndceN7sMaZ0KIOhCGX cxCk1Jsu//19dJ5PkBSFC5DSGAPZkVH6Y0HYDYLQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 4D0AF3858C27 for ; Wed, 13 Oct 2021 12:19:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4D0AF3858C27 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-out1.suse.de (Postfix) with ESMTPS id 872F3222FD; Wed, 13 Oct 2021 12:19:38 +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 6E60513CEC; Wed, 13 Oct 2021 12:19:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id jYTXGdrOZmFDCgAAMHmgww (envelope-from ); Wed, 13 Oct 2021 12:19:38 +0000 Date: Wed, 13 Oct 2021 14:19:38 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Add GSI_LAST_NEW_STMT iterator update Message-ID: MIME-Version: 1.0 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.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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Cc: richard.sandiford@arm.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Currently when adding a sequence before there's no way to get the iterator placed at the last added stmt which results in convoluted code in the if-conversion usecase. The following adds GSI_LAST_NEW_STMT and corrects one obvious mistake in execute_update_addresses_taken as well as tries to avoid the just filed PR102726 by biasing the enum values to be outside of the boolean 0/1 range. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Will push once that succeeded. Richard. 2021-10-13 Richard Biener * gimple-iterator.h (gsi_iterator_update): Add GSI_LAST_NEW_STMT, start at integer value 2. * gimple-iterator.c (gsi_insert_seq_nodes_before): Update the iterator for GSI_LAST_NEW_STMT. (gsi_insert_seq_nodes_after): Likewise. * tree-if-conv.c (predicate_statements): Use GSI_LAST_NEW_STMT. * tree-ssa.c (execute_update_addresses_taken): Correct bogus arguments to gsi_replace. --- gcc/gimple-iterator.c | 4 ++++ gcc/gimple-iterator.h | 4 ++-- gcc/tree-if-conv.c | 6 +----- gcc/tree-ssa.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c index da8c21297de..ee4e63a3bd3 100644 --- a/gcc/gimple-iterator.c +++ b/gcc/gimple-iterator.c @@ -162,6 +162,9 @@ gsi_insert_seq_nodes_before (gimple_stmt_iterator *i, case GSI_CONTINUE_LINKING: i->ptr = first; break; + case GSI_LAST_NEW_STMT: + i->ptr = last; + break; case GSI_SAME_STMT: break; default: @@ -271,6 +274,7 @@ gsi_insert_seq_nodes_after (gimple_stmt_iterator *i, case GSI_NEW_STMT: i->ptr = first; break; + case GSI_LAST_NEW_STMT: case GSI_CONTINUE_LINKING: i->ptr = last; break; diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h index 6047a739332..0e384f72f94 100644 --- a/gcc/gimple-iterator.h +++ b/gcc/gimple-iterator.h @@ -46,8 +46,8 @@ struct gphi_iterator : public gimple_stmt_iterator enum gsi_iterator_update { - GSI_NEW_STMT, /* Only valid when single statement is added, move - iterator to it. */ + GSI_NEW_STMT = 2, /* Move the iterator to the first statement added. */ + GSI_LAST_NEW_STMT, /* Move the iterator to the last statement added. */ GSI_SAME_STMT, /* Leave the iterator at the same statement. */ GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable for linking other statements in the same diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 6a67acfeaae..0b6b07cfac6 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -2582,11 +2582,7 @@ predicate_statements (loop_p loop) { gsi_remove (&gsi, true); gsi_insert_seq_before (&gsi, rewrite_to_defined_overflow (stmt), - GSI_SAME_STMT); - if (gsi_end_p (gsi)) - gsi = gsi_last_bb (gimple_bb (stmt)); - else - gsi_prev (&gsi); + GSI_LAST_NEW_STMT); } else if (gimple_vdef (stmt)) { diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 0fba404babe..fde13defebf 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -2079,7 +2079,7 @@ execute_update_addresses_taken (void) gcall *call = gimple_build_call_internal (IFN_ASAN_POISON, 0); gimple_call_set_lhs (call, var); - gsi_replace (&gsi, call, GSI_SAME_STMT); + gsi_replace (&gsi, call, true); } else { @@ -2088,7 +2088,7 @@ execute_update_addresses_taken (void) previous out of scope value. */ tree clobber = build_clobber (TREE_TYPE (var)); gimple *g = gimple_build_assign (var, clobber); - gsi_replace (&gsi, g, GSI_SAME_STMT); + gsi_replace (&gsi, g, true); } continue; }