public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Make vector lowering use vectors of proper sign
@ 2012-03-14 14:54 Richard Guenther
  2012-03-20  9:25 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Guenther @ 2012-03-14 14:54 UTC (permalink / raw)
  To: gcc-patches


I noticed when trying to fix PR52584 that vector lowering always
creates unsigned vector types.  The following fixes that, also
getting rid of the weird use of a langhook.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Richard.

2012-03-14  Richard Guenther  <rguenther@suse.de>

	PR middle-end/52584
	* tree-vect-generic.c (type_for_widest_vector_mode): Take
	element type instead of mode, use build_vector_type_for_mode
	instead of the langhook, build a vector of proper signedness.
	(expand_vector_operations_1): Adjust.

Index: gcc/tree-vect-generic.c
===================================================================
*** gcc/tree-vect-generic.c	(revision 185379)
--- gcc/tree-vect-generic.c	(working copy)
*************** expand_vector_operation (gimple_stmt_ite
*** 471,483 ****
  				    gimple_assign_rhs2 (assign), code);
  }
  \f
! /* Return a type for the widest vector mode whose components are of mode
!    INNER_MODE, or NULL_TREE if none is found.
!    SATP is true for saturating fixed-point types.  */
  
  static tree
! type_for_widest_vector_mode (enum machine_mode inner_mode, optab op, int satp)
  {
    enum machine_mode best_mode = VOIDmode, mode;
    int best_nunits = 0;
  
--- 471,483 ----
  				    gimple_assign_rhs2 (assign), code);
  }
  \f
! /* Return a type for the widest vector mode whose components are of type
!    TYPE, or NULL_TREE if none is found.  */
  
  static tree
! type_for_widest_vector_mode (tree type, optab op)
  {
+   enum machine_mode inner_mode = TYPE_MODE (type);
    enum machine_mode best_mode = VOIDmode, mode;
    int best_nunits = 0;
  
*************** type_for_widest_vector_mode (enum machin
*** 503,515 ****
    if (best_mode == VOIDmode)
      return NULL_TREE;
    else
!     {
!       /* For fixed-point modes, we need to pass satp as the 2nd parameter.  */
!       if (ALL_FIXED_POINT_MODE_P (best_mode))
! 	return lang_hooks.types.type_for_mode (best_mode, satp);
! 
!       return lang_hooks.types.type_for_mode (best_mode, 1);
!     }
  }
  
  
--- 503,509 ----
    if (best_mode == VOIDmode)
      return NULL_TREE;
    else
!     return build_vector_type_for_mode (type, best_mode);
  }
  
  
*************** expand_vector_operations_1 (gimple_stmt_
*** 856,863 ****
    if (!VECTOR_MODE_P (TYPE_MODE (type)) && op)
      {
        tree vector_compute_type
!         = type_for_widest_vector_mode (TYPE_MODE (TREE_TYPE (type)), op,
! 				       TYPE_SATURATING (TREE_TYPE (type)));
        if (vector_compute_type != NULL_TREE
  	  && (TYPE_VECTOR_SUBPARTS (vector_compute_type)
  	      < TYPE_VECTOR_SUBPARTS (compute_type))
--- 850,856 ----
    if (!VECTOR_MODE_P (TYPE_MODE (type)) && op)
      {
        tree vector_compute_type
!         = type_for_widest_vector_mode (TREE_TYPE (type), op);
        if (vector_compute_type != NULL_TREE
  	  && (TYPE_VECTOR_SUBPARTS (vector_compute_type)
  	      < TYPE_VECTOR_SUBPARTS (compute_type))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Make vector lowering use vectors of proper sign
  2012-03-14 14:54 [PATCH] Make vector lowering use vectors of proper sign Richard Guenther
@ 2012-03-20  9:25 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2012-03-20  9:25 UTC (permalink / raw)
  To: gcc-patches

Il 14/03/2012 15:53, Richard Guenther ha scritto:
> 
> I noticed when trying to fix PR52584 that vector lowering always
> creates unsigned vector types.  The following fixes that, also
> getting rid of the weird use of a langhook.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> Richard.
> 
> 2012-03-14  Richard Guenther  <rguenther@suse.de>
> 
> 	PR middle-end/52584
> 	* tree-vect-generic.c (type_for_widest_vector_mode): Take
> 	element type instead of mode, use build_vector_type_for_mode
> 	instead of the langhook, build a vector of proper signedness.
> 	(expand_vector_operations_1): Adjust.
> 
> Index: gcc/tree-vect-generic.c
> ===================================================================
> *** gcc/tree-vect-generic.c	(revision 185379)
> --- gcc/tree-vect-generic.c	(working copy)
> *************** expand_vector_operation (gimple_stmt_ite
> *** 471,483 ****
>   				    gimple_assign_rhs2 (assign), code);
>   }
>   \f
> ! /* Return a type for the widest vector mode whose components are of mode
> !    INNER_MODE, or NULL_TREE if none is found.
> !    SATP is true for saturating fixed-point types.  */
>   
>   static tree
> ! type_for_widest_vector_mode (enum machine_mode inner_mode, optab op, int satp)
>   {
>     enum machine_mode best_mode = VOIDmode, mode;
>     int best_nunits = 0;
>   
> --- 471,483 ----
>   				    gimple_assign_rhs2 (assign), code);
>   }
>   \f
> ! /* Return a type for the widest vector mode whose components are of type
> !    TYPE, or NULL_TREE if none is found.  */
>   
>   static tree
> ! type_for_widest_vector_mode (tree type, optab op)
>   {
> +   enum machine_mode inner_mode = TYPE_MODE (type);
>     enum machine_mode best_mode = VOIDmode, mode;
>     int best_nunits = 0;
>   
> *************** type_for_widest_vector_mode (enum machin
> *** 503,515 ****
>     if (best_mode == VOIDmode)
>       return NULL_TREE;
>     else
> !     {
> !       /* For fixed-point modes, we need to pass satp as the 2nd parameter.  */
> !       if (ALL_FIXED_POINT_MODE_P (best_mode))
> ! 	return lang_hooks.types.type_for_mode (best_mode, satp);
> ! 
> !       return lang_hooks.types.type_for_mode (best_mode, 1);
> !     }
>   }
>   
>   
> --- 503,509 ----
>     if (best_mode == VOIDmode)
>       return NULL_TREE;
>     else
> !     return build_vector_type_for_mode (type, best_mode);
>   }
>   
>   
> *************** expand_vector_operations_1 (gimple_stmt_
> *** 856,863 ****
>     if (!VECTOR_MODE_P (TYPE_MODE (type)) && op)
>       {
>         tree vector_compute_type
> !         = type_for_widest_vector_mode (TYPE_MODE (TREE_TYPE (type)), op,
> ! 				       TYPE_SATURATING (TREE_TYPE (type)));
>         if (vector_compute_type != NULL_TREE
>   	  && (TYPE_VECTOR_SUBPARTS (vector_compute_type)
>   	      < TYPE_VECTOR_SUBPARTS (compute_type))
> --- 850,856 ----
>     if (!VECTOR_MODE_P (TYPE_MODE (type)) && op)
>       {
>         tree vector_compute_type
> !         = type_for_widest_vector_mode (TREE_TYPE (type), op);
>         if (vector_compute_type != NULL_TREE
>   	  && (TYPE_VECTOR_SUBPARTS (vector_compute_type)
>   	      < TYPE_VECTOR_SUBPARTS (compute_type))
> 

Looks good.

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-20  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-14 14:54 [PATCH] Make vector lowering use vectors of proper sign Richard Guenther
2012-03-20  9:25 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).