From a44ae25817b7d796c0c1d57eaa3101f682f80a57 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 23 May 2019 18:07:07 +0200 Subject: [PATCH] re PR tree-optimization/90576 (SPEC CPU2006 450.soplex miscompiled with -Os -flto after r271413) PR tree-optimization/90576 * tree-ssa-alias.c (compare_sizes): Remove dead calls to poly_int_tree_p. (aliasing_component_refs_p): Fix three way size compare conditional; give up earlier in case we can not decide on equivalence. Co-Authored-By: Martin Liska From-SVN: r271572 --- gcc/ChangeLog | 9 +++++++++ gcc/tree-ssa-alias.c | 21 +++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3b91d4befab..ff91bfe77fa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2019-05-23 Jan Hubicka + Martin Liska + + PR tree-optimization/90576 + * tree-ssa-alias.c (compare_sizes): Remove dead calls to + poly_int_tree_p. + (aliasing_component_refs_p): Fix three way size compare conditional; + give up earlier in case we can not decide on equivalence. + 2019-05-23 Bill Schmidt Michael Meissner Segher Boessenkool diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 5b5f1462463..33c15f52beb 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -746,8 +746,8 @@ compare_sizes (tree s1, tree s2) if (!s1 || !s2) return 0; - poly_uint64 size1 = poly_int_tree_p (s1, &size1); - poly_uint64 size2 = poly_int_tree_p (s2, &size2); + poly_uint64 size1; + poly_uint64 size2; if (!poly_int_tree_p (s1, &size1) || !poly_int_tree_p (s2, &size2)) return 0; @@ -873,7 +873,7 @@ aliasing_component_refs_p (tree ref1, break; /* If types may be of same size, see if we can decide about their equality. */ - if (cmp >= 0) + if (cmp == 0) { same_p2 = same_type_for_tbaa (TREE_TYPE (*refp), type1); if (same_p2 != 0) @@ -915,7 +915,7 @@ aliasing_component_refs_p (tree ref1, break; /* If types may be of same size, see if we can decide about their equality. */ - if (cmp >= 0) + if (cmp == 0) { same_p1 = same_type_for_tbaa (TREE_TYPE (*refp), type2); if (same_p1 != 0) @@ -947,6 +947,13 @@ aliasing_component_refs_p (tree ref1, } } + /* In the following code we make an assumption that the types in access + paths do not overlap and thus accesses alias only if one path can be + continuation of another. If we was not able to decide about equivalence, + we need to give up. */ + if (same_p1 == -1 || same_p2 == -1) + return true; + /* If we have two type access paths B1.path1 and B2.path2 they may only alias if either B1 is in B2.path2 or B2 is in B1.path1. But we can still have a path that goes B1.path1...B2.path2 with @@ -954,8 +961,7 @@ aliasing_component_refs_p (tree ref1, if there is no B2 in the tail of path1 and no B1 on the tail of path2. */ if (compare_type_sizes (TREE_TYPE (ref2), type1) >= 0 - && (same_p2 == -1 - || base1_alias_set == ref2_alias_set + && (base1_alias_set == ref2_alias_set || alias_set_subset_of (base1_alias_set, ref2_alias_set))) { ++alias_stats.aliasing_component_refs_p_may_alias; @@ -964,8 +970,7 @@ aliasing_component_refs_p (tree ref1, /* If this is ptr vs. decl then we know there is no ptr ... decl path. */ if (!ref2_is_decl && compare_type_sizes (TREE_TYPE (ref1), type2) >= 0 - && (same_p1 == -1 - || base2_alias_set == ref1_alias_set + && (base2_alias_set == ref1_alias_set || alias_set_subset_of (base2_alias_set, ref1_alias_set))) { ++alias_stats.aliasing_component_refs_p_may_alias; -- 2.30.2