From patchwork Tue Jul 26 10:08:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp2161939pxt; Tue, 26 Jul 2022 03:09:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tV+OitgjCKdkdp5t6qfBbLdn5DmCKZD9OPNZVvuJV00wjpBtTMEtDXtsLgRetwaYiFiclz X-Received: by 2002:a17:906:7308:b0:72f:3294:8002 with SMTP id di8-20020a170906730800b0072f32948002mr12932347ejc.311.1658830186094; Tue, 26 Jul 2022 03:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658830186; cv=none; d=google.com; s=arc-20160816; b=jAheoe7iG7PD9MYLIWmOwgYJqu9Kl/aGIfW4P2mDTqRt69FCfwjdQuPBLM84eSWVjq YjYi2JRbowpFx1aAYkl54A7tqkWTW8iJ1Ppd/3fHB86ud+z5+o/5/zb5ilb3Np6UUGTV RCvhUJAJEvBNdjdhT6E5raoJ8VK77UxeEFWd1M/XPQs+d5ngLc7rhcfJS+AWEGvOgsrE PH+Ejx1+VRb8PAA+8kKHBPS8exc4qWNuh/zWC0V5ZpGTYAAlfB50QS1hJdxh4nwVNfCt 1XOKnGrey8rB7NklpH6dMTtphBoNrLqWpP3843zbq8QQcn69aEVlcnPE8U52yG9UzP0P MbLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=gBTdeDt9iXbbh/1xGAiZGiIMuNv2gdigtzNxvVcgrxQ=; b=qbbFa7S9JLSK9JKiL1EIjnM/gsuAWQoSM9Ap5OCb8QsDPED9GhWRZQVPXJQ5AAVjRs Y2sytDMAPh2qY9QT7lDtEZd53Q+/tiT1s5IJc61abovzkNztX09I+9DF5s3azkU/l/zA 9uSumyXvgpF2TlqxjbmT+TQvUHF3Qw6rrGmEzyRAO1ZuCzcI2M7ERou6eYmAVufRffat +AP/7VBLDlUsydqpIUSRro0/3wL/tBfDHarLwuAnRoYL8D/o2xNyjqTliuMZmefHbqkw 4dGNcqBlQJr+eKus/FEkbReQ91T/TjbPvFNRY00jjG854j3HN+ABuqrEJPV0d+/M82NR QQYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pep7LOhP; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a21-20020a1709066d5500b0071223d9f214si9445287ejt.177.2022.07.26.03.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 03:09:46 -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=@gcc.gnu.org header.s=default header.b=pep7LOhP; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B18AE3858009 for ; Tue, 26 Jul 2022 10:09:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B18AE3858009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658830184; bh=gBTdeDt9iXbbh/1xGAiZGiIMuNv2gdigtzNxvVcgrxQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pep7LOhPTytcVZkdUNXbKwtQZiNeMN2VzMb3UJQ/rQnwltHZ7gqISd2tZvUzzGaS/ LLM2F+Ry04hq/v5QdjtObxtpgei7Ymqh+884xVW/PwC3sBXh0EIgH1hocYSyYoW9sU ZQQfpq3FzQl0eY5gb3zrV3S+y9QHCbyDn4pbW7QQ= 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.220.29]) by sourceware.org (Postfix) with ESMTPS id 05983385828A for ; Tue, 26 Jul 2022 10:08:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05983385828A Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0185A1FB0E for ; Tue, 26 Jul 2022 10:08:35 +0000 (UTC) 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 F04822C15D for ; Tue, 26 Jul 2022 10:08:34 +0000 (UTC) Date: Tue, 26 Jul 2022 10:08:34 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Improve ptr_derefs_may_alias_p for the case of &STRING_CST 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.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 Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20220726100944.B18AE3858009@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739409521302200438?= X-GMAIL-MSGID: =?utf-8?q?1739409521302200438?= When the first pointer happens to be a pointer to a STRING_CST we give up too early since the 2nd pointer handling could still end up with a DECL for example which can disambiguate against a STRING_CST just fine. Boostrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-ssa-alias.cc (ptr_derefs_may_alias_p): If ptr1 points to a constant continue checking ptr2. --- gcc/tree-ssa-alias.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index 390cd875074..b4c65da5718 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -349,7 +349,9 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2) else if (base && DECL_P (base)) return ptr_deref_may_alias_decl_p (ptr2, base); - else + /* Try ptr2 when ptr1 points to a constant. */ + else if (base + && !CONSTANT_CLASS_P (base)) return true; } if (TREE_CODE (ptr2) == ADDR_EXPR)