This makes sure that opaque vector types are treated as compatible
with their non-opaque variant (something that they certainly should be).
I made them variant types instead of completely separate types,
also making sure we properly share them.

Bootstrapped and tested on x86_64-unknown-linux-gnu ontop of a patch
that will excercise them on this target.

Committed.

Richard.

2011-09-27  Richard Guenther  <rguent...@suse.de>

        * 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.

Index: gcc/tree.c
===================================================================
*** gcc/tree.c  (revision 179308)
--- gcc/tree.c  (working copy)
*************** build_vector_type (tree innertype, int n
*** 9752,9768 ****
    return make_vector_type (innertype, nunits, VOIDmode);
  }
  
! /* Similarly, but takes the inner type and number of units, which must be
!    a power of two.  */
  
  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;
  }
  
  
--- 9752,9780 ----
    return make_vector_type (innertype, nunits, VOIDmode);
  }
  
! /* Similarly, but builds a variant type with TYPE_VECTOR_OPAQUE set.  */
  
  tree
  build_opaque_vector_type (tree innertype, int nunits)
  {
!   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;
  }
  
  

Reply via email to