From patchwork Tue Feb 13 11:43:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 200397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp476696dyb; Tue, 13 Feb 2024 03:43:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwT1tSKo6/KPtwCpuvF3hTckUhvU8itYgjhCf9xIw+A6dd/pe93/0ER5dCgMlBD33r54C2HHf5YM534rN+KoZ6IvxR8Q== X-Google-Smtp-Source: AGHT+IGAuGUdpAhe5Pt2h2dx1Y5xPMiM0QK309XmfQxN7h4ru+93MSWtqKpfNxVdN9CwFCP103hv X-Received: by 2002:ac8:5889:0:b0:42c:557b:87f2 with SMTP id t9-20020ac85889000000b0042c557b87f2mr4512124qta.23.1707824619969; Tue, 13 Feb 2024 03:43:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707824619; cv=pass; d=google.com; s=arc-20160816; b=j9/KV+TbkQfbSW1d2tNOPPYUzUWSr9pqgzwMhQ0IBYSbqnH1CK2uDAi0g6FpEz9Ezb dJk0GTvbf+t+mrLvpzymeoXNZ9/5/3Lg5ctNk7cBzoRSwogrsortbIeoNjY1gWPcQXEC MB9Ku3vR8jyUJljquSuT3Y580VKCHCcbQPqoYqFNIQgEUB0LUSkW65JFrDET9AVEdJJO f1K6tUFRawzhOvnjILRTkIrcWcEQFqLJA/OPjbjnwxF80uF5NeyaqIYq2vY9Vtfk5QfT dVb/Hg6buS7WqGZxUUWPkFbHpYwohfirzWejMvQRoeuJfewDDgtUI7d/LWFXr/Ga9zg4 /WXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :subject:to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=rHYA6+kO7V9EFm74BPawobqRT0jpXTWhTjO9gDBIFy8=; fh=5llai72yX+S5lhL+ouZC5fq/hEFSM2QNyfW8nCC5i+s=; b=ihsmhC3zIpueOY8nsIEDXPlQ0Uy9+AGQEqgzwXY0ICn1wJ7f8Fbwegc1yAJWVdR24k xPEdh/y7XFOWARzjkRmE819Id4k7fdaepu+SC58ZPGxtI1GiRXobuTNDbXhBbqA0ehEr 8iAiDtVFo18dejccdaBBhYnTGHGrpwXuHc91mATGR64BL80vLgfvmjIpEOmw6ONWOtjY M5M5d1Hi4ngf7yz2/N6OcehFLQ25uA3ewA25MSXPRIvHXm0ogKbGu9fPlHGH1v1iCiIc BWLawjg9ucjgDrfUOJZcnDQcuzXl+McGIXFCZV4V4j4PuCVC7JeFzfEHa1ZDg/jyGcs3 mY0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Vc5aaCic; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Vc5aaCic; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=2; AJvYcCU6NU71hBRm/MNRVWxzE5Uwpta3BdQ9dVD4QtGtiQjj2d8d9fJ/J7oKaXlH1Z5UqQXtWXlNsicWQfxVzdVmPnVmLjr7Nw== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z9-20020ac875c9000000b0042da968cef7si1998951qtq.543.2024.02.13.03.43.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 03:43:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Vc5aaCic; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Vc5aaCic; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F2D9385829E for ; Tue, 13 Feb 2024 11:43:39 +0000 (GMT) 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 [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 8DDE23858410 for ; Tue, 13 Feb 2024 11:43:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DDE23858410 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 8DDE23858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707824585; cv=none; b=fkdJVF9FU5gaDudiznRvoFkezPK8t1e0IQBBOFIoeM5kj0u8otSWsZqBnr8vJ2aPijT2NLDLZnqrn53A0wAdyz7cENR2rv5vXnyWn3Y8tRRPtR2uSlmM6eIZtohLfsyUeKkjy4xE2Vq93Sgv2s89gnbt3VhhKg9lkuTvLbfMHO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707824585; c=relaxed/simple; bh=rh5toWlJcTr9/ZEOo9HMLss9ogPYr6Nhd7R6IMvl4jY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=bsv68nSi1eONxl+lrr5wRAyVaXKGb7wImFMzgNfv0Vc+aDYbeRj2JcJvTAHM9Z2eswb6HnBgzb9zmbldDRZvTCYiBniTSd9/da7p80SOkOITxoNGgw9V/ve1PYy6bDldentQ+Ms1oX+rJ+0EDpG2FuRd5STSTBql983cg9qbhAE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (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-out1.suse.de (Postfix) with ESMTPS id 89B8E21CAA for ; Tue, 13 Feb 2024 11:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707824581; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rHYA6+kO7V9EFm74BPawobqRT0jpXTWhTjO9gDBIFy8=; b=Vc5aaCicc/Uf4KTxpN3AtyzACpimEgB5XhQSXafXWGYOlIi7k8WKX48nCyK/Ykzn6b3uQ5 affMha4omDg2Mge+Hy6U/V5XNQfqufPoAPpNWKeAGM6vZZ0D6r+p5C9agJ7QUtgdO5HGKA veaAp9C3hewOC76Nq7wRlU92CKFfXDg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707824581; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rHYA6+kO7V9EFm74BPawobqRT0jpXTWhTjO9gDBIFy8=; b=9I8Vag8UbQMsYemDiHoIvnwWDd+MToHiBhKVMYefB8kol6lEi2pKr6Xb2qxv+HAbZMQbut WU0BxcJ94o4owMBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707824581; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rHYA6+kO7V9EFm74BPawobqRT0jpXTWhTjO9gDBIFy8=; b=Vc5aaCicc/Uf4KTxpN3AtyzACpimEgB5XhQSXafXWGYOlIi7k8WKX48nCyK/Ykzn6b3uQ5 affMha4omDg2Mge+Hy6U/V5XNQfqufPoAPpNWKeAGM6vZZ0D6r+p5C9agJ7QUtgdO5HGKA veaAp9C3hewOC76Nq7wRlU92CKFfXDg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707824581; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rHYA6+kO7V9EFm74BPawobqRT0jpXTWhTjO9gDBIFy8=; b=9I8Vag8UbQMsYemDiHoIvnwWDd+MToHiBhKVMYefB8kol6lEi2pKr6Xb2qxv+HAbZMQbut WU0BxcJ94o4owMBw== Date: Tue, 13 Feb 2024 12:43:01 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/113902 - fix VUSE update in move_early_exit_stmts MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [-0.60 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Spam-Score: -0.60 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, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20240213114339.9F2D9385829E@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790783908689680911 X-GMAIL-MSGID: 1790783908689680911 The following adjusts move_early_exit_stmts to track the last seen VUSE instead of getting it from the last store which could be a PHI where gimple_vuse doesn't work. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/113902 * tree-vect-loop.cc (move_early_exit_stmts): Track last_seen_vuse for VUSE updating. * gcc.dg/vect/pr113902.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr113902.c | 15 +++++++++++++++ gcc/tree-vect-loop.cc | 12 +++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr113902.c diff --git a/gcc/testsuite/gcc.dg/vect/pr113902.c b/gcc/testsuite/gcc.dg/vect/pr113902.c new file mode 100644 index 00000000000..a2fe3df26e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr113902.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-add-options vect_early_break } */ + +int g_66, g_80_2; +void func_1func_41(int p_43) +{ +lbl_1434: + g_80_2 = 0; + for (; g_80_2 <= 7; g_80_2 += 1) { + g_66 = 0; + for (; g_66 <= 7; g_66 += 1) + if (p_43) + goto lbl_1434; + } +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 04f4b5b6b2f..4e498bb45ad 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -11787,6 +11787,7 @@ move_early_exit_stmts (loop_vec_info loop_vinfo) basic_block dest_bb = LOOP_VINFO_EARLY_BRK_DEST_BB (loop_vinfo); gimple_stmt_iterator dest_gsi = gsi_after_labels (dest_bb); + tree last_seen_vuse = NULL_TREE; for (gimple *stmt : LOOP_VINFO_EARLY_BRK_STORES (loop_vinfo)) { /* We have to update crossed degenerate virtual PHIs. Simply @@ -11805,6 +11806,7 @@ move_early_exit_stmts (loop_vec_info loop_vinfo) } auto gsi = gsi_for_stmt (stmt); remove_phi_node (&gsi, true); + last_seen_vuse = vuse; continue; } @@ -11819,17 +11821,17 @@ move_early_exit_stmts (loop_vec_info loop_vinfo) gimple_stmt_iterator stmt_gsi = gsi_for_stmt (stmt); gsi_move_before (&stmt_gsi, &dest_gsi, GSI_NEW_STMT); + last_seen_vuse = gimple_vuse (stmt); } /* Update all the stmts with their new reaching VUSES. */ - tree vuse - = gimple_vuse (LOOP_VINFO_EARLY_BRK_STORES (loop_vinfo).last ()); for (auto p : LOOP_VINFO_EARLY_BRK_VUSES (loop_vinfo)) { if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, - "updating vuse to %T for load %G", vuse, p); - gimple_set_vuse (p, vuse); + "updating vuse to %T for load %G", + last_seen_vuse, p); + gimple_set_vuse (p, last_seen_vuse); update_stmt (p); } @@ -11837,7 +11839,7 @@ move_early_exit_stmts (loop_vec_info loop_vinfo) for (edge e : get_loop_exit_edges (LOOP_VINFO_LOOP (loop_vinfo))) if (!dominated_by_p (CDI_DOMINATORS, e->src, dest_bb)) if (gphi *phi = get_virtual_phi (e->dest)) - SET_PHI_ARG_DEF_ON_EDGE (phi, e, vuse); + SET_PHI_ARG_DEF_ON_EDGE (phi, e, last_seen_vuse); } /* Function vect_transform_loop.