From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) From: Richard Biener 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 Content-Type: text/plain; charset=US-ASCII 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-List-Received-Date: Tue, 26 Jul 2022 10:08:37 -0000 Message-ID: <20220726100834.zXLg9lEmdEeVIcUPPU268ogtRjzzliI-jbdwn2CaTtw@z> 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) -- 2.35.3