From 011d9d1639f6cdac670237f36144739b938a6c38 Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 9 Apr 2010 13:21:43 +0000 Subject: [PATCH] 2010-04-09 Richard Guenther * target.h (builtin_conversion): Pass in input and output types. * targhooks.c (default_builtin_vectorized_conversion): Adjust. * targhooks.h (default_builtin_vectorized_conversion): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Adjust. * doc/tm.texi (TARGET_VECTORIZE_BUILTIN_CONVERSION): Adjust. * config/i386/i386.c (ix86_vectorize_builtin_conversion): Adjust. Handle AVX modes. * config/rs6000/rs6000.c (rs6000_builtin_conversion): Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158162 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 12 ++++++++ gcc/config/i386/i386.c | 75 ++++++++++++++++++++++++++++++++++++++-------- gcc/config/rs6000/rs6000.c | 20 ++++++------- gcc/doc/tm.texi | 8 ++--- gcc/target.h | 6 ++-- gcc/targhooks.c | 3 +- gcc/targhooks.h | 2 +- gcc/tree-vect-stmts.c | 8 ++--- 8 files changed, 95 insertions(+), 39 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0db0161..ce2a495 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,17 @@ 2010-04-09 Richard Guenther + * target.h (builtin_conversion): Pass in input and output types. + * targhooks.c (default_builtin_vectorized_conversion): Adjust. + * targhooks.h (default_builtin_vectorized_conversion): Likewise. + * tree-vect-stmts.c (vectorizable_conversion): Adjust. + * doc/tm.texi (TARGET_VECTORIZE_BUILTIN_CONVERSION): Adjust. + + * config/i386/i386.c (ix86_vectorize_builtin_conversion): Adjust. + Handle AVX modes. + * config/rs6000/rs6000.c (rs6000_builtin_conversion): Adjust. + +2010-04-09 Richard Guenther + PR target/43152 * config/i386/sse.md (vcond): Handle AVX modes as well. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index f65220c..407e37c 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -24691,43 +24691,92 @@ ix86_veclibabi_acml (enum built_in_function fn, tree type_out, tree type_in) /* Returns a decl of a function that implements conversion of an integer vector - into a floating-point vector, or vice-versa. TYPE is the type of the integer - side of the conversion. + into a floating-point vector, or vice-versa. DEST_TYPE and SRC_TYPE + are the types involved when converting according to CODE. Return NULL_TREE if it is not available. */ static tree -ix86_vectorize_builtin_conversion (unsigned int code, tree type) +ix86_vectorize_builtin_conversion (unsigned int code, + tree dest_type, tree src_type) { - if (! (TARGET_SSE2 && TREE_CODE (type) == VECTOR_TYPE)) + if (! TARGET_SSE2) return NULL_TREE; switch (code) { case FLOAT_EXPR: - switch (TYPE_MODE (type)) + switch (TYPE_MODE (src_type)) { case V4SImode: - return TYPE_UNSIGNED (type) - ? ix86_builtins[IX86_BUILTIN_CVTUDQ2PS] - : ix86_builtins[IX86_BUILTIN_CVTDQ2PS]; + switch (TYPE_MODE (dest_type)) + { + case V4SFmode: + return (TYPE_UNSIGNED (src_type) + ? ix86_builtins[IX86_BUILTIN_CVTUDQ2PS] + : ix86_builtins[IX86_BUILTIN_CVTDQ2PS]); + case V4DFmode: + return (TYPE_UNSIGNED (src_type) + ? NULL_TREE + : ix86_builtins[IX86_BUILTIN_CVTDQ2PD256]); + default: + return NULL_TREE; + } + break; + case V8SImode: + switch (TYPE_MODE (dest_type)) + { + case V8SFmode: + return (TYPE_UNSIGNED (src_type) + ? NULL_TREE + : ix86_builtins[IX86_BUILTIN_CVTDQ2PS]); + default: + return NULL_TREE; + } + break; default: return NULL_TREE; } case FIX_TRUNC_EXPR: - switch (TYPE_MODE (type)) + switch (TYPE_MODE (dest_type)) { case V4SImode: - return TYPE_UNSIGNED (type) - ? NULL_TREE - : ix86_builtins[IX86_BUILTIN_CVTTPS2DQ]; + switch (TYPE_MODE (src_type)) + { + case V4SFmode: + return (TYPE_UNSIGNED (dest_type) + ? NULL_TREE + : ix86_builtins[IX86_BUILTIN_CVTTPS2DQ]); + case V4DFmode: + return (TYPE_UNSIGNED (dest_type) + ? NULL_TREE + : ix86_builtins[IX86_BUILTIN_CVTTPD2DQ256]); + default: + return NULL_TREE; + } + break; + + case V8SImode: + switch (TYPE_MODE (src_type)) + { + case V8SFmode: + return (TYPE_UNSIGNED (dest_type) + ? NULL_TREE + : ix86_builtins[IX86_BUILTIN_CVTTPS2DQ256]); + default: + return NULL_TREE; + } + break; + default: return NULL_TREE; } + default: return NULL_TREE; - } + + return NULL_TREE; } /* Returns a code for a target-specific builtin that implements diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 91f66a9..2817706 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -990,7 +990,7 @@ static tree rs6000_builtin_reciprocal (unsigned int, bool, bool); static tree rs6000_builtin_mask_for_load (void); static tree rs6000_builtin_mul_widen_even (tree); static tree rs6000_builtin_mul_widen_odd (tree); -static tree rs6000_builtin_conversion (unsigned int, tree); +static tree rs6000_builtin_conversion (unsigned int, tree, tree); static tree rs6000_builtin_vec_perm (tree, tree *); static bool rs6000_builtin_support_vector_misalignment (enum machine_mode, @@ -2883,24 +2883,24 @@ rs6000_builtin_mask_for_load (void) /* Implement targetm.vectorize.builtin_conversion. Returns a decl of a function that implements conversion of an integer vector - into a floating-point vector, or vice-versa. TYPE is the type of the integer - side of the conversion. + into a floating-point vector, or vice-versa. DEST_TYPE is the + destination type and SRC_TYPE the source type of the conversion. Return NULL_TREE if it is not available. */ static tree -rs6000_builtin_conversion (unsigned int tcode, tree type) +rs6000_builtin_conversion (unsigned int tcode, tree dest_type, tree src_type) { enum tree_code code = (enum tree_code) tcode; switch (code) { case FIX_TRUNC_EXPR: - switch (TYPE_MODE (type)) + switch (TYPE_MODE (dest_type)) { case V2DImode: if (!VECTOR_UNIT_VSX_P (V2DFmode)) return NULL_TREE; - return TYPE_UNSIGNED (type) + return TYPE_UNSIGNED (dest_type) ? rs6000_builtin_decls[VSX_BUILTIN_XVCVDPUXDS_UNS] : rs6000_builtin_decls[VSX_BUILTIN_XVCVDPSXDS]; @@ -2908,7 +2908,7 @@ rs6000_builtin_conversion (unsigned int tcode, tree type) if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode)) return NULL_TREE; - return TYPE_UNSIGNED (type) + return TYPE_UNSIGNED (dest_type) ? rs6000_builtin_decls[VECTOR_BUILTIN_FIXUNS_V4SF_V4SI] : rs6000_builtin_decls[VECTOR_BUILTIN_FIX_V4SF_V4SI]; @@ -2917,13 +2917,13 @@ rs6000_builtin_conversion (unsigned int tcode, tree type) } case FLOAT_EXPR: - switch (TYPE_MODE (type)) + switch (TYPE_MODE (src_type)) { case V2DImode: if (!VECTOR_UNIT_VSX_P (V2DFmode)) return NULL_TREE; - return TYPE_UNSIGNED (type) + return TYPE_UNSIGNED (src_type) ? rs6000_builtin_decls[VSX_BUILTIN_XVCVUXDDP] : rs6000_builtin_decls[VSX_BUILTIN_XVCVSXDDP]; @@ -2931,7 +2931,7 @@ rs6000_builtin_conversion (unsigned int tcode, tree type) if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode)) return NULL_TREE; - return TYPE_UNSIGNED (type) + return TYPE_UNSIGNED (src_type) ? rs6000_builtin_decls[VECTOR_BUILTIN_UNSFLOAT_V4SI_V4SF] : rs6000_builtin_decls[VECTOR_BUILTIN_FLOAT_V4SI_V4SF]; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 8337e16..51172e4 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5700,13 +5700,9 @@ Target builtin that implements vector permute. Return true if a vector created for @code{builtin_vec_perm} is valid. @end deftypefn -@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_CONVERSION (unsigned @var{code}, tree @var{type}) +@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_CONVERSION (unsigned @var{code}, tree @var{dest_type}, tree @var{src_type}) This hook should return the DECL of a function that implements conversion of the -input vector of type @var{type}. -If @var{type} is an integral type, the result of the conversion is a vector of -floating-point type of the same size. -If @var{type} is a floating-point type, the result of the conversion is a vector -of integral type of the same size. +input vector of type @var{src_type} to type @var{dest_type}. The value of @var{code} is one of the enumerators in @code{enum tree_code} and specifies how the conversion is to be applied (truncation, rounding, etc.). diff --git a/gcc/target.h b/gcc/target.h index e4e82a3..7729525 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -476,9 +476,9 @@ struct gcc_target function, or NULL_TREE if not available. */ tree (* builtin_vectorized_function) (tree, tree, tree); - /* Returns a code for builtin that realizes vectorized version of - conversion, or NULL_TREE if not available. */ - tree (* builtin_conversion) (unsigned, tree); + /* Returns a function declaration for a builtin that realizes the + vector conversion, or NULL_TREE if not available. */ + tree (* builtin_conversion) (unsigned, tree, tree); /* Target builtin that implements vector widening multiplication. builtin_mul_widen_eve computes the element-by-element products diff --git a/gcc/targhooks.c b/gcc/targhooks.c index d9a7a9d..00fa502 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -430,7 +430,8 @@ default_builtin_vectorized_function (tree fndecl ATTRIBUTE_UNUSED, tree default_builtin_vectorized_conversion (unsigned int code ATTRIBUTE_UNUSED, - tree type ATTRIBUTE_UNUSED) + tree dest_type ATTRIBUTE_UNUSED, + tree src_type ATTRIBUTE_UNUSED) { return NULL_TREE; } diff --git a/gcc/targhooks.h b/gcc/targhooks.h index b2b9097..209ed79 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -72,7 +72,7 @@ extern const char * default_invalid_within_doloop (const_rtx); extern tree default_builtin_vectorized_function (tree, tree, tree); -extern tree default_builtin_vectorized_conversion (unsigned int, tree); +extern tree default_builtin_vectorized_conversion (unsigned int, tree, tree); extern tree default_builtin_reciprocal (unsigned int, bool, bool); diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 26b9ca2..4868f73 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1564,7 +1564,6 @@ vectorizable_conversion (gimple stmt, gimple_stmt_iterator *gsi, int i; VEC(tree,heap) *vec_oprnds0 = NULL; tree vop0; - tree integral_type; VEC(tree,heap) *dummy = NULL; int dummy_int; @@ -1620,8 +1619,6 @@ vectorizable_conversion (gimple stmt, gimple_stmt_iterator *gsi, else return false; - integral_type = INTEGRAL_TYPE_P (rhs_type) ? vectype_in : vectype_out; - if (modifier == NARROW) ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits_out; else @@ -1638,7 +1635,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_iterator *gsi, /* Supportable by target? */ if ((modifier == NONE - && !targetm.vectorize.builtin_conversion (code, integral_type)) + && !targetm.vectorize.builtin_conversion (code, vectype_out, vectype_in)) || (modifier == WIDEN && !supportable_widening_operation (code, stmt, vectype_out, vectype_in, @@ -1689,7 +1686,8 @@ vectorizable_conversion (gimple stmt, gimple_stmt_iterator *gsi, vect_get_vec_defs_for_stmt_copy (dt, &vec_oprnds0, NULL); builtin_decl = - targetm.vectorize.builtin_conversion (code, integral_type); + targetm.vectorize.builtin_conversion (code, + vectype_out, vectype_in); for (i = 0; VEC_iterate (tree, vec_oprnds0, i, vop0); i++) { /* Arguments are ready. create the new vector stmt. */ -- 2.7.4