From patchwork Thu Oct 5 08:25:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 148674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp145702vqb; Thu, 5 Oct 2023 01:26:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpXpfVcG+eIrr5O4R6rE9Op6RE8/99isKMa9AVHZZC6C2NhB+o/61IDC+yt9vYV4VD1pP7 X-Received: by 2002:a05:6402:217:b0:533:4c15:c337 with SMTP id t23-20020a056402021700b005334c15c337mr3825303edv.16.1696494361085; Thu, 05 Oct 2023 01:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696494361; cv=none; d=google.com; s=arc-20160816; b=FZ0WgAg9eGx8UUkyuJTqwp2nRmyZr+mzUBW261l0tokV2sxivRlu9diB5NNb+KxsID GXJo06oGMbC4XEz/w0RODV8rTpTY9lwCRuTJnsQrcFIabUr26529GJGkEYVKfYhyVDqL K3b7B/ShD6vs2LfgFCDpAMvRxdxssDo7qcQlwgON1EcAPqhAyq6gxXSvIWsg8NeMfJM4 WckAhiqT1ycIX0AMeM+JaPd7QmBDMqGeBfDEAGSGoWMmGbIFriDxW61YAOgRYL2Wxipy z0J4NAhluaiI11h9lATA/+sxHxnlAdWk1HDJSDi/L7/Jr2ysK7Tv5/3WVtQ9hGhSOz8Q oD+A== ARC-Message-Signature: i=1; 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 :user-agent:subject:to:from:date:dkim-signature:dkim-signature :dmarc-filter:delivered-to; bh=ZcVZFeE5jv1/EpRorhUmUGLVUnUAl7+X5RzLuS+oW6w=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=ZjrZKJ5wvcJJEfFhNe+r8V8CWARuQImWgp7X2z9d7nyzySdT6dnMSFxxWBwXvPSrPX PsSBe3MUqyyOvhCtkLtQBFOokX3ztR6aDGZ8Tm9nwLn5sPGAlQ3AAv7Bd08fzlueYflk z2uebk9IxZUK7sXAoxkzbLvnFlERRmO+xNf08I40phwYnUlcNO5DmoL0iN3y+GkuMP1M 7dzQcdgkX+QR5AsffJeZQw4D5ZFYRR0pcI9CicCEDCfGvaZnFDOtX8VfRSSLSoHjB0hD +6kN+O46Q5M+ZDihtz0+FKLtTHJgV1nhr2Nswh+0FXAvt3fbNOM9bgsKDeA/HHejcPWb c/Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=U7ShKADF; dkim=neutral (no key) header.i=@suse.de; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x9-20020aa7d389000000b0053494e0d24esi532589edq.108.2023.10.05.01.26.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 01:26:01 -0700 (PDT) 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=U7ShKADF; dkim=neutral (no key) header.i=@suse.de; 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 8C3A83857C66 for ; Thu, 5 Oct 2023 08:25:59 +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:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 074BF3857C66 for ; Thu, 5 Oct 2023 08:25:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 074BF3857C66 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 relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2AC8621838 for ; Thu, 5 Oct 2023 08:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696494306; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=ZcVZFeE5jv1/EpRorhUmUGLVUnUAl7+X5RzLuS+oW6w=; b=U7ShKADFiiPtH36hJf9olA5oiNN0ZQExWS4l2ghcdEhNrDGQTIgZS3oeLi65V40cTp1jbH TFQbiZQDrUO0F8yrssiUP9iDBpDmP0CTNOdffuKmTyk+zBpOrJ0ddsNHs5Nm+/m8/p/+/o 887fT3AQE9ho/9fQiGdxKOBjOCqHeZ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696494306; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=ZcVZFeE5jv1/EpRorhUmUGLVUnUAl7+X5RzLuS+oW6w=; b=KtTXoSjahpvJsX1K8HukwfBH3MjsGob12C5OOaIfjYSF39rCA7BckINikIvWBVCZWFt7xB UN6w/QKcz1ITURBw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 075802C142 for ; Thu, 5 Oct 2023 08:25:06 +0000 (UTC) Date: Thu, 5 Oct 2023 08:25:06 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid left around copies when value-numbering BBs User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 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 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: <20231005082559.8C3A83857C66@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778903270753400860 X-GMAIL-MSGID: 1778903270753400860 The following makes sure to treat values whose definition we didn't visit as available since those by definition must dominate the entry of the region. That avoids unpropagated copies after if-conversion and resulting SLP discovery fails (which doesn't handle plain copies). Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-ssa-sccvn.cc (rpo_elim::eliminate_avail): Not visited value numbers are available itself. --- gcc/tree-ssa-sccvn.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index e46498568cb..d2aab38c2d2 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -7688,7 +7688,11 @@ rpo_elim::eliminate_avail (basic_block bb, tree op) { if (SSA_NAME_IS_DEFAULT_DEF (valnum)) return valnum; - vn_avail *av = VN_INFO (valnum)->avail; + vn_ssa_aux_t valnum_info = VN_INFO (valnum); + /* See above. */ + if (!valnum_info->visited) + return valnum; + vn_avail *av = valnum_info->avail; if (!av) return NULL_TREE; if (av->location == bb->index)