From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106176 invoked by alias); 17 Jun 2019 13:41:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 106168 invoked by uid 89); 17 Jun 2019 13:41:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=involving X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Jun 2019 13:41:28 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 22E42ADF0; Mon, 17 Jun 2019 13:41:26 +0000 (UTC) Date: Mon, 17 Jun 2019 13:41:00 -0000 From: Richard Biener To: Jan Hubicka cc: gcc-patches@gcc.gnu.org, d@dcepelik.cz, ebotcazou@adacore.com Subject: Re: Remove nonoverlapping_component_refs_of_decl_p In-Reply-To: <20190617124645.5q25gkit7ofx4v7e@kam.mff.cuni.cz> Message-ID: References: <20190614105656.jf4rddqhjjgrteaz@kam.mff.cuni.cz> <20190614112452.ydsqbo5ouxsuc2p2@kam.mff.cuni.cz> <20190614201548.rfkpgm3n3ftq5tl3@kam.mff.cuni.cz> <20190617070245.uy2sfzyhd4ojvo62@kam.mff.cuni.cz> <20190617102334.zozwxicfyrnq4sq6@kam.mff.cuni.cz> <20190617124645.5q25gkit7ofx4v7e@kam.mff.cuni.cz> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="-1609908220-1490604561-1560778886=:10704" X-SW-Source: 2019-06/txt/msg00951.txt.bz2 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1609908220-1490604561-1560778886=:10704 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT Content-length: 6134 On Mon, 17 Jun 2019, Jan Hubicka wrote: > Hi, > this is patch for aliasing_component_refs_p and VCE. > I also turned the refp to ref, but there are no changes relative > to that. > Bootstrapped/regtested x86_64-linux, OK? OK. Bonus points for wrong-code testcases involving these... like the following which doesn't fail for some reason: struct S { int i; int j[2]; }; __GIMPLE(startwith("fre1")) int foo(struct S *x, struct S *y) { int _1; x->j[0] = 1; __VIEW_CONVERT (__MEM ((int(*)[2])y + 4)).i = 0; _1 = x->j[0]; return _1; } int main() { struct S s; if (foo (&s, &s) != 0) __builtin_abort (); return 0; } Thanks, Richard. > Honza > > * tree-ssa-alias.c (aliasing_component_refs_p): Consider only > the access path from base to first VIEW_CONVERT_EXPR or > BIT_FIELD_REF. > Index: tree-ssa-alias.c > =================================================================== > --- tree-ssa-alias.c (revision 272381) > +++ tree-ssa-alias.c (working copy) > @@ -874,7 +874,6 @@ aliasing_component_refs_p (tree ref1, > disambiguating q->i and p->a.j. */ > tree base1, base2; > tree type1, type2; > - tree *refp; > int same_p1 = 0, same_p2 = 0; > bool maybe_match = false; > tree end_struct_ref1 = NULL, end_struct_ref2 = NULL; > @@ -903,6 +902,9 @@ aliasing_component_refs_p (tree ref1, > gcc_checking_assert (!end_struct_ref1); > end_struct_ref1 = base1; > } > + if (TREE_CODE (base1) == VIEW_CONVERT_EXPR > + || TREE_CODE (base1) == BIT_FIELD_REF) > + ref1 = TREE_OPERAND (base1, 0); > base1 = TREE_OPERAND (base1, 0); > } > type1 = TREE_TYPE (base1); > @@ -918,6 +920,9 @@ aliasing_component_refs_p (tree ref1, > gcc_checking_assert (!end_struct_ref2); > end_struct_ref2 = base2; > } > + if (TREE_CODE (base2) == VIEW_CONVERT_EXPR > + || TREE_CODE (base2) == BIT_FIELD_REF) > + ref2 = TREE_OPERAND (base2, 0); > base2 = TREE_OPERAND (base2, 0); > } > type2 = TREE_TYPE (base2); > @@ -934,23 +939,23 @@ aliasing_component_refs_p (tree ref1, > || (end_struct_ref2 > && compare_type_sizes (TREE_TYPE (end_struct_ref2), type1) >= 0)) > { > - refp = &ref2; > + tree ref = ref2; > while (true) > { > /* We walk from inner type to the outer types. If type we see is > already too large to be part of type1, terminate the search. */ > - int cmp = compare_type_sizes (type1, TREE_TYPE (*refp)); > + int cmp = compare_type_sizes (type1, TREE_TYPE (ref)); > > if (cmp < 0 > && (!end_struct_ref1 > || compare_type_sizes (TREE_TYPE (end_struct_ref1), > - TREE_TYPE (*refp)) < 0)) > + TREE_TYPE (ref)) < 0)) > break; > /* If types may be of same size, see if we can decide about their > equality. */ > if (cmp == 0) > { > - same_p2 = same_type_for_tbaa (TREE_TYPE (*refp), type1); > + same_p2 = same_type_for_tbaa (TREE_TYPE (ref), type1); > if (same_p2 == 1) > break; > /* In case we can't decide whether types are same try to > @@ -960,9 +965,9 @@ aliasing_component_refs_p (tree ref1, > if (same_p2 == -1) > maybe_match = true; > } > - if (!handled_component_p (*refp)) > + if (!handled_component_p (ref)) > break; > - refp = &TREE_OPERAND (*refp, 0); > + ref = TREE_OPERAND (ref, 0); > } > if (same_p2 == 1) > { > @@ -977,13 +982,13 @@ aliasing_component_refs_p (tree ref1, > if (TREE_CODE (TREE_TYPE (base1)) == ARRAY_TYPE > && (!TYPE_SIZE (TREE_TYPE (base1)) > || TREE_CODE (TYPE_SIZE (TREE_TYPE (base1))) != INTEGER_CST > - || (*refp == base2 && !ref2_is_decl))) > + || (ref == base2 && !ref2_is_decl))) > { > ++alias_stats.aliasing_component_refs_p_may_alias; > return true; > } > > - get_ref_base_and_extent (*refp, &offadj, &sztmp, &msztmp, &reverse); > + get_ref_base_and_extent (ref, &offadj, &sztmp, &msztmp, &reverse); > offset2 -= offadj; > get_ref_base_and_extent (base1, &offadj, &sztmp, &msztmp, &reverse); > offset1 -= offadj; > @@ -1005,28 +1010,28 @@ aliasing_component_refs_p (tree ref1, > || (end_struct_ref1 > && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0)) > { > - refp = &ref1; > + tree ref = ref1; > while (true) > { > - int cmp = compare_type_sizes (type2, TREE_TYPE (*refp)); > + int cmp = compare_type_sizes (type2, TREE_TYPE (ref)); > if (cmp < 0 > && (!end_struct_ref2 > || compare_type_sizes (TREE_TYPE (end_struct_ref2), > - TREE_TYPE (*refp)) < 0)) > + TREE_TYPE (ref)) < 0)) > break; > /* If types may be of same size, see if we can decide about their > equality. */ > if (cmp == 0) > { > - same_p1 = same_type_for_tbaa (TREE_TYPE (*refp), type2); > + same_p1 = same_type_for_tbaa (TREE_TYPE (ref), type2); > if (same_p1 == 1) > break; > if (same_p1 == -1) > maybe_match = true; > } > - if (!handled_component_p (*refp)) > + if (!handled_component_p (ref)) > break; > - refp = &TREE_OPERAND (*refp, 0); > + ref = TREE_OPERAND (ref, 0); > } > if (same_p1 == 1) > { > @@ -1036,13 +1041,13 @@ aliasing_component_refs_p (tree ref1, > if (TREE_CODE (TREE_TYPE (base2)) == ARRAY_TYPE > && (!TYPE_SIZE (TREE_TYPE (base2)) > || TREE_CODE (TYPE_SIZE (TREE_TYPE (base2))) != INTEGER_CST > - || (*refp == base1 && !ref2_is_decl))) > + || (ref == base1 && !ref2_is_decl))) > { > ++alias_stats.aliasing_component_refs_p_may_alias; > return true; > } > > - get_ref_base_and_extent (*refp, &offadj, &sztmp, &msztmp, &reverse); > + get_ref_base_and_extent (ref, &offadj, &sztmp, &msztmp, &reverse); > offset1 -= offadj; > get_ref_base_and_extent (base2, &offadj, &sztmp, &msztmp, &reverse); > offset2 -= offadj; > -- Richard Biener SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer, Mary Higgins, Sri Rasiah; HRB 21284 (AG Nürnberg) ---1609908220-1490604561-1560778886=:10704--