From patchwork Mon Dec 28 12:16:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 561286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7129C140C50 for ; Mon, 28 Dec 2015 23:16:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KjK/Uz1x; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=yt4nN54r4T0vCECeYJx45cpDc5yikQJeaZyMUMwF3xj fC3sm5LkoBUvv+vcNkQlo0Z1v18hiv+AMgpAf2PF5ceXtY88EYQVsjzBYqR6M33H WXpIigRJl0EU9XryzlfWQfMM1NpY79sr6CMQq0+0DLmMaxPOfEajE5QxB062RtFo = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=bc/+s1J2P3xoyiPNLvYDequR7Jw=; b=KjK/Uz1xgOdsfVqqa hzJ94joBtv24J3Hl7a5j1Y4/rWeZRaSYfNpF4+BTgLmltjOlZv4wlujV9N0lPeiY a6oZ+mb40m93d6f9dnDQSIwo5oIXkNRQuS3q+ZTvDHwJ3ENIGKvZ3TCSw3qWRsjL LtcEa6ONqps8TI1eiOFFrKf7qQ= Received: (qmail 54921 invoked by alias); 28 Dec 2015 12:16:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 54910 invoked by uid 89); 28 Dec 2015 12:16:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=Label, oracle, s2, conservative X-HELO: mail-ob0-f179.google.com Received: from mail-ob0-f179.google.com (HELO mail-ob0-f179.google.com) (209.85.214.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 28 Dec 2015 12:16:31 +0000 Received: by mail-ob0-f179.google.com with SMTP id ba1so139624082obb.3 for ; Mon, 28 Dec 2015 04:16:31 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.135.98 with SMTP id pr2mr23004254oeb.65.1451304989279; Mon, 28 Dec 2015 04:16:29 -0800 (PST) Received: by 10.60.138.70 with HTTP; Mon, 28 Dec 2015 04:16:29 -0800 (PST) Date: Mon, 28 Dec 2015 13:16:29 +0100 Message-ID: Subject: Re: Fix alias.c wrt aliases and anchors From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" Cc: Jan Hubicka , Richard Biener , Richard Sandiford Hello! >> Yeah, I think handling anchors is a good thing. It just seems that >> logically the correctness fix is to replace: >> >> /* Label and normal symbol are never the same. */ >> if (x_decl != y_decl) >> return 0; >> return offset_overlap_p (c, xsize, ysize); >> >> with something like: >> >> if (XSTR (x, 0) == XSTR (y, 0)) >> return offset_overlap_p (c, xsize, ysize); >> /* Symbols might conflict. */ >> return -1; >> >> Handling anchors would then be a very useful optimisation on top of that. > > Ah, OK, now I get your point :) > Yep, I have no problem beling conservative for non-anchor cases !SYMBOL_REF_DECL case. > Pretty much all cases that matter are IMO either anchors or SYMBOL_REF_DECL != NULL. > (i.e. user variables). > > I will update the patch and also look into the Alpha AND issues. I have another version of the patch that deals with AND addresses in testing, please see attached. The difference from the previous patch is: @@ -2339,6 +2337,12 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, r /* If both decls are the same, decide by offsets. */ if (cmp == 1) return offset_overlap_p (c, xsize, ysize); + /* Assume a potential overlap for symbolic addresses that went + through alignment adjustments (i.e., that have negative + sizes), because we can't know how far they are from each + other. */ + if (xsize < 0 || ysize < 0) + return -1; /* If decls are different or we know by offsets that there is no overlap, we win. */ if (!cmp || !offset_overlap_p (c, xsize, ysize)) So, we simply return unknown from memrefs_conflict_p when realignment is in play. (We still need early return for AND addresses in base_alias_check, though). Uros. Index: alias.c =================================================================== --- alias.c (revision 231971) +++ alias.c (working copy) @@ -2046,8 +2046,6 @@ compare_base_decls (tree base1, tree base2) ret = symtab_node::get_create (base1)->equal_address_to (symtab_node::get_create (base2), true); - if (ret == 2) - return -1; return ret; } @@ -2088,17 +2086,6 @@ base_alias_check (rtx x, rtx x_base, rtx y, rtx y_ if (rtx_equal_p (x_base, y_base)) return 1; - if (GET_CODE (x_base) == SYMBOL_REF && GET_CODE (y_base) == SYMBOL_REF) - { - tree x_decl = SYMBOL_REF_DECL (x_base); - tree y_decl = SYMBOL_REF_DECL (y_base); - - /* We can assume that no stores are made to labels. */ - if (!x_decl || !y_decl) - return 0; - return compare_base_decls (x_decl, y_decl) != 0; - } - /* The base addresses are different expressions. If they are not accessed via AND, there is no conflict. We can bring knowledge of object alignment into play here. For example, on alpha, "char a, b;" can @@ -2117,6 +2104,17 @@ base_alias_check (rtx x, rtx x_base, rtx y, rtx y_ || (int) GET_MODE_UNIT_SIZE (x_mode) < -INTVAL (XEXP (y, 1)))) return 1; + if (GET_CODE (x_base) == SYMBOL_REF && GET_CODE (y_base) == SYMBOL_REF) + { + tree x_decl = SYMBOL_REF_DECL (x_base); + tree y_decl = SYMBOL_REF_DECL (y_base); + + /* We can assume that no stores are made to labels. */ + if (!x_decl || !y_decl) + return 0; + return compare_base_decls (x_decl, y_decl) != 0; + } + /* Differing symbols not accessed via AND never alias. */ if (GET_CODE (x_base) != ADDRESS && GET_CODE (y_base) != ADDRESS) return 0; @@ -2339,6 +2337,12 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, r /* If both decls are the same, decide by offsets. */ if (cmp == 1) return offset_overlap_p (c, xsize, ysize); + /* Assume a potential overlap for symbolic addresses that went + through alignment adjustments (i.e., that have negative + sizes), because we can't know how far they are from each + other. */ + if (xsize < 0 || ysize < 0) + return -1; /* If decls are different or we know by offsets that there is no overlap, we win. */ if (!cmp || !offset_overlap_p (c, xsize, ysize)) Index: symtab.c =================================================================== --- symtab.c (revision 231971) +++ symtab.c (working copy) @@ -1877,7 +1877,7 @@ symtab_node::nonzero_address () /* Return 0 if symbol is known to have different address than S2, Return 1 if symbol is known to have same address as S2, - return 2 otherwise. + return -1 otherwise. If MEMORY_ACCESSED is true, assume that both memory pointer to THIS and S2 is going to be accessed. This eliminates the situations when @@ -1941,7 +1941,7 @@ symtab_node::equal_address_to (symtab_node *s2, bo /* If both symbols may resolve to NULL, we can not really prove them different. */ if (!memory_accessed && !nonzero_address () && !s2->nonzero_address ()) - return 2; + return -1; /* Except for NULL, functions and variables never overlap. */ if (TREE_CODE (decl) != TREE_CODE (s2->decl)) @@ -1949,7 +1949,7 @@ symtab_node::equal_address_to (symtab_node *s2, bo /* If one of the symbols is unresolved alias, punt. */ if (rs1->alias || rs2->alias) - return 2; + return -1; /* If we have a non-interposale definition of at least one of the symbols and the other symbol is different, we know other unit can not interpose @@ -1976,7 +1976,7 @@ symtab_node::equal_address_to (symtab_node *s2, bo We probably should be consistent and use this fact here, too, but for the moment return false only when we are called from the alias oracle. */ - return memory_accessed && rs1 != rs2 ? 0 : 2; + return memory_accessed && rs1 != rs2 ? 0 : -1; } /* Worker for call_for_symbol_and_aliases. */