This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for PR21969 (large vector causes ICE)


Here is a new patch for PR 21969.  It issues no error messages but
stores log2(n) for vector sizes of size n.  This means there is no
overflow unless the vectors have more than 2**256 elements which I don't
think can happen.  I originally did not include a cast in the
TYPE_VECTOR_SUBPARTS macro but that resulted in a warning in
fold_ternary (fold-const.c).  I added the cast and that resulted in a
warning in vect_transform_loop (tree-vect-transform.c) so I left the
cast in the TYPE_VECTOR_SUBPARTS macro and added a cast to
vect_transform_loop to make that warnings go away.

Tested on IA64 HP-UX and Linux with no regressions.

Steve Ellcey
sje@cup.hp.com


2005-06-27  Steve Ellcey  <sje@cup.hp.com>

	PR middle-end/21969
	* tree.h (TYPE_VECTOR_SUBPARTS): Change to shift expression.
	(SET_TYPE_VECTOR_SUBPARTS): New.
	* tree.c (make_vector_type): Replace TYPE_VECTOR_SUBPARTS with
	SET_TYPE_VECTOR_SUBPARTS.
	* tree-vect-transform.c (vect_transform_loop): Add cast.


testsuite ChangeLog:


2005-06-27  Steve Ellcey  <sje@cup.hp.com>

	PR middle-end/21969
	* gcc.dg/vect/pr21969.c: New test.



*** gcc.orig/gcc/tree.h	Mon Jun 27 13:56:23 2005
--- gcc/gcc/tree.h	Mon Jun 27 14:09:33 2005
*************** struct tree_block GTY(())
*** 1665,1673 ****
  #define TYPE_ARRAY_MAX_SIZE(ARRAY_TYPE) \
    (ARRAY_TYPE_CHECK (ARRAY_TYPE)->type.maxval)
  
! /* For a VECTOR_TYPE, this is the number of sub-parts of the vector.  */
  #define TYPE_VECTOR_SUBPARTS(VECTOR_TYPE) \
!   (VECTOR_TYPE_CHECK (VECTOR_TYPE)->type.precision)
  
  /* Indicates that objects of this type must be initialized by calling a
     function when they are created.  */
--- 1665,1679 ----
  #define TYPE_ARRAY_MAX_SIZE(ARRAY_TYPE) \
    (ARRAY_TYPE_CHECK (ARRAY_TYPE)->type.maxval)
  
! /* For a VECTOR_TYPE, this is log2 of the number of sub-parts of the
!    vector.  The number of sub-parts is always a power of 2.  */
  #define TYPE_VECTOR_SUBPARTS(VECTOR_TYPE) \
!   (((unsigned HOST_WIDE_INT) 1) \
!    << VECTOR_TYPE_CHECK (VECTOR_TYPE)->type.precision)
! 
! /* Set precision to n when we have 2^n sub-parts of the vector.  */
! #define SET_TYPE_VECTOR_SUBPARTS(VECTOR_TYPE, X) \
!   (VECTOR_TYPE_CHECK (VECTOR_TYPE)->type.precision = exact_log2 ((X) & -(X)))
  
  /* Indicates that objects of this type must be initialized by calling a
     function when they are created.  */
*** gcc.orig/gcc/tree.c	Mon Jun 27 13:56:20 2005
--- gcc/gcc/tree.c	Mon Jun 27 13:55:01 2005
*************** make_vector_type (tree innertype, int nu
*** 5710,5716 ****
    tree t = make_node (VECTOR_TYPE);
  
    TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype);
!   TYPE_VECTOR_SUBPARTS (t) = nunits;
    TYPE_MODE (t) = mode;
    TYPE_READONLY (t) = TYPE_READONLY (innertype);
    TYPE_VOLATILE (t) = TYPE_VOLATILE (innertype);
--- 5710,5716 ----
    tree t = make_node (VECTOR_TYPE);
  
    TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype);
!   SET_TYPE_VECTOR_SUBPARTS (t, nunits);
    TYPE_MODE (t) = mode;
    TYPE_READONLY (t) = TYPE_READONLY (innertype);
    TYPE_VOLATILE (t) = TYPE_VOLATILE (innertype);
*** gcc.orig/gcc/tree-vect-transform.c	Mon Jun 27 13:56:32 2005
--- gcc/gcc/tree-vect-transform.c	Mon Jun 27 13:55:15 2005
*************** vect_transform_loop (loop_vec_info loop_
*** 2111,2117 ****
  	             units and no inner unrolling is necessary.  */
  	  gcc_assert 
  		(TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info))
! 		 == vectorization_factor);
  #endif
  	  /* -------- vectorize statement ------------ */
  	  if (vect_print_dump_info (REPORT_DETAILS, UNKNOWN_LOC))
--- 2111,2117 ----
  	             units and no inner unrolling is necessary.  */
  	  gcc_assert 
  		(TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info))
! 		 == (unsigned HOST_WIDE_INT) vectorization_factor);
  #endif
  	  /* -------- vectorize statement ------------ */
  	  if (vect_print_dump_info (REPORT_DETAILS, UNKNOWN_LOC))
*** gcc.orig/gcc/testsuite/gcc.dg/vect/pr21969.c	Mon Jun 20 09:44:36 2005
--- gcc/gcc/testsuite/gcc.dg/vect/pr21969.c	Mon Jun 27 13:47:24 2005
***************
*** 0 ****
--- 1,4 ----
+ /* { dg-do compile } */
+ /* { dg-require-effective-target vect_float } */
+ 
+ typedef float vsf __attribute__((vector_size(2048)));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]