From: Richard Guenther Date: Thu, 29 Sep 2011 11:26:46 +0000 (+0000) Subject: tree.c (build_opaque_vector_type): Make opaque vectors variant types of the correspon... X-Git-Tag: releases/gcc-4.7.0~3475 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7c99ecef0b605466c522f4c170811761339dac16;p=thirdparty%2Fgcc.git tree.c (build_opaque_vector_type): Make opaque vectors variant types of the corresponding non-opaque type. 2011-09-29 Richard Guenther * tree.c (build_opaque_vector_type): Make opaque vectors variant types of the corresponding non-opaque type. Make sure to share opaque vector types properly. From-SVN: r179341 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 972e1f9e337f..30fa460b1395 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-09-29 Richard Guenther + + * tree.c (build_opaque_vector_type): Make opaque vectors + variant types of the corresponding non-opaque type. Make + sure to share opaque vector types properly. + 2011-09-29 David S. Miller * config/sparc/sparc.md (UNSPEC_ARRAY8, UNSPEC_ARRAY16, diff --git a/gcc/tree.c b/gcc/tree.c index a53c9f432eef..bcdda5034aa7 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -9752,17 +9752,29 @@ build_vector_type (tree innertype, int nunits) return make_vector_type (innertype, nunits, VOIDmode); } -/* Similarly, but takes the inner type and number of units, which must be - a power of two. */ +/* Similarly, but builds a variant type with TYPE_VECTOR_OPAQUE set. */ tree build_opaque_vector_type (tree innertype, int nunits) { - tree t; - innertype = build_distinct_type_copy (innertype); - t = make_vector_type (innertype, nunits, VOIDmode); - TYPE_VECTOR_OPAQUE (t) = true; - return t; + tree t = make_vector_type (innertype, nunits, VOIDmode); + tree cand; + /* We always build the non-opaque variant before the opaque one, + so if it already exists, it is TYPE_NEXT_VARIANT of this one. */ + cand = TYPE_NEXT_VARIANT (t); + if (cand + && TYPE_VECTOR_OPAQUE (cand) + && check_qualified_type (cand, t, TYPE_QUALS (t))) + return cand; + /* Othewise build a variant type and make sure to queue it after + the non-opaque type. */ + cand = build_distinct_type_copy (t); + TYPE_VECTOR_OPAQUE (cand) = true; + TYPE_CANONICAL (cand) = TYPE_CANONICAL (t); + TYPE_NEXT_VARIANT (cand) = TYPE_NEXT_VARIANT (t); + TYPE_NEXT_VARIANT (t) = cand; + TYPE_MAIN_VARIANT (cand) = TYPE_MAIN_VARIANT (t); + return cand; }