From patchwork Tue May 21 08:51:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 90557 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 DEF3D3858D3C for ; Tue, 21 May 2024 08:52:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 6EA3B3858D1E for ; Tue, 21 May 2024 08:51:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EA3B3858D1E 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 6EA3B3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716281499; cv=none; b=omsFQncKwbX3c0zIBcn4IPi+A3s4S1OnH9ehBTlk3coP3xQ9EqhDnmu8RihOwcV8QhNyGp62qCM0dePktz77QLFYDfIwCB78mDPJM/6ETiufpKIe6ahI3CxINHVwG2BB3xbBn9VVOf4+nmCkKSPgWj7TTvNN4a+MaRnhRxxsh+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716281499; c=relaxed/simple; bh=vTJIIY9Wcv1TwjGRfjfSNITYyxm3VJrvSshfHUZPp1A=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=wj+hb4a2LT0GoNmi98vIaEuN/Wstw1r1XDOysLYTh82pPgcXoM/pC0DzyQm4PAxmgk8pI6pZdgmKgojD5CwDdGCxeRzPUF0rKHajyfKTNBxTCAA3m/MV/WATY6GpDeLQDUghT9rz1+7FBfSHfZNUfZL+QksEcolsASkcQJ8giuk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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-out2.suse.de (Postfix) with ESMTPS id 314985BFC0 for ; Tue, 21 May 2024 08:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716281496; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ja2x6jfNce458d+AVqNAog44Z2nJAYKLxbgtrEVrlKA=; b=zX5mErbkfG9QjN7uAsOxpJvjBXVX/DDnKCXbBSV3QeLSSekBWle7NzE7MwU/D92tc/bzVu UBAMiFRcmELUv71ae55vTKq87CzXNsJRQMyIMEpJgKfE+ZOl1Ul/9vNQI4snh5I8LHFCBg U3LgcDFtNLKVeKe/Nl3RLAxHbZ9FIIo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716281496; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ja2x6jfNce458d+AVqNAog44Z2nJAYKLxbgtrEVrlKA=; b=Uxo2AWYgb7B+qMegqM65XrZ0i380oFDf/g3HLwY//3Lw3lTFNBNPY6tspGe+iZ2nFGuSvq usgKVLZ1B25vl5AA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zX5mErbk; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Uxo2AWYg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716281496; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ja2x6jfNce458d+AVqNAog44Z2nJAYKLxbgtrEVrlKA=; b=zX5mErbkfG9QjN7uAsOxpJvjBXVX/DDnKCXbBSV3QeLSSekBWle7NzE7MwU/D92tc/bzVu UBAMiFRcmELUv71ae55vTKq87CzXNsJRQMyIMEpJgKfE+ZOl1Ul/9vNQI4snh5I8LHFCBg U3LgcDFtNLKVeKe/Nl3RLAxHbZ9FIIo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716281496; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Ja2x6jfNce458d+AVqNAog44Z2nJAYKLxbgtrEVrlKA=; b=Uxo2AWYgb7B+qMegqM65XrZ0i380oFDf/g3HLwY//3Lw3lTFNBNPY6tspGe+iZ2nFGuSvq usgKVLZ1B25vl5AA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 17F1E13A1E for ; Tue, 21 May 2024 08:51:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +5wwBJhgTGYuKQAAD6G6ig (envelope-from ) for ; Tue, 21 May 2024 08:51:36 +0000 Date: Tue, 21 May 2024 10:51:35 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/115149 - VOP live and missing PHIs MIME-Version: 1.0 Message-Id: <20240521085136.17F1E13A1E@imap1.dmz-prg2.suse.org> X-Spam-Score: -6.51 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 314985BFC0 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-6.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_ONE(0.00)[1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; MISSING_XM_UA(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.de:dkim] X-Spam-Status: No, score=-11.6 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 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+patchwork=sourceware.org@gcc.gnu.org The following fixes a bug in vop-live get_live_in which was using NULL to indicate the first processed edge but at the same time using it for the case the live-in virtual operand cannot be computed. The following fixes this, avoiding sinking a load to a place where we'd have to insert virtual PHIs to make the virtual operand SSA web OK. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/115149 * tree-ssa-live.cc (virtual_operand_live::get_live_in): Explicitly track the first processed edge. * gcc.dg/pr115149.c: New testcase. --- gcc/testsuite/gcc.dg/pr115149.c | 16 ++++++++++++++++ gcc/tree-ssa-live.cc | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr115149.c diff --git a/gcc/testsuite/gcc.dg/pr115149.c b/gcc/testsuite/gcc.dg/pr115149.c new file mode 100644 index 00000000000..9f6bc97dbe6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr115149.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-inline -fno-tree-vrp -fno-ipa-sra -fno-tree-dce -fno-tree-ch" } */ + +int a, c, e, f, g, h[1], i; +static int j(int b) { return 0; } +static void k(int d) {} +int main() +{ + if (h[0]) + while (1) { + k(f && j(i && (h[g] = e))); + while (a) + c ^= 1; + } + return 0; +} diff --git a/gcc/tree-ssa-live.cc b/gcc/tree-ssa-live.cc index e6ae551a457..60dfc05dcd9 100644 --- a/gcc/tree-ssa-live.cc +++ b/gcc/tree-ssa-live.cc @@ -1675,14 +1675,18 @@ virtual_operand_live::get_live_in (basic_block bb) edge_iterator ei; edge e; tree livein = NULL_TREE; + bool first = true; FOR_EACH_EDGE (e, ei, bb->preds) if (e->flags & EDGE_DFS_BACK) /* We can ignore backedges since if there's a def there it would have forced a PHI in the source because it also acts as use downstream. */ continue; - else if (!livein) - livein = get_live_out (e->src); + else if (first) + { + livein = get_live_out (e->src); + first = false; + } else if (get_live_out (e->src) != livein) /* When there's no virtual use downstream this indicates a point where we'd insert a PHI merging the different live virtual