invoke.texi (-mveclibabi): Document new target option.

2007-08-30  Richard Guenther  <rguenther@suse.de>

	* doc/invoke.texi (-mveclibabi): Document new target option.
	* config/i386/i386.opt (-mveclibabi): New target option.
	* config/i386/i386.c (ix86_veclib_handler): Handler for
	vectorization library support.
	(override_options): Handle the -mveclibabi option, initialize
	the vectorization library handler.
	(ix86_builtin_vectorized_function): As fallback call the
	vectorization library handler, if set.
	(ix86_veclibabi_acml): New static function for ACML ABI style
	vectorization support.

	* gcc.target/i386/vectorize5.c: New testcase.

From-SVN: r127926
This commit is contained in:
Richard Guenther 2007-08-30 13:55:42 +00:00 committed by Richard Biener
parent e9f63ace23
commit a5ea943cb8
6 changed files with 159 additions and 5 deletions

View File

@ -1,3 +1,16 @@
2007-08-30 Richard Guenther <rguenther@suse.de>
* doc/invoke.texi (-mveclibabi): Document new target option.
* config/i386/i386.opt (-mveclibabi): New target option.
* config/i386/i386.c (ix86_veclib_handler): Handler for
vectorization library support.
(override_options): Handle the -mveclibabi option, initialize
the vectorization library handler.
(ix86_builtin_vectorized_function): As fallback call the
vectorization library handler, if set.
(ix86_veclibabi_acml): New static function for ACML ABI style
vectorization support.
2007-08-30 Jakub Jelinek <jakub@redhat.com>
* config/rs6000/rs6000.c (rs6000_emit_sync): For QI or HI mode

View File

@ -1620,6 +1620,10 @@ static int ix86_isa_flags_explicit;
#define OPTION_MASK_ISA_SSE4A_UNSET OPTION_MASK_ISA_SSE4
/* Vectorization library interface and handlers. */
tree (*ix86_veclib_handler)(enum built_in_function, tree, tree) = NULL;
static tree ix86_veclibabi_acml (enum built_in_function, tree, tree);
/* Implement TARGET_HANDLE_OPTION. */
static bool
@ -2409,6 +2413,16 @@ override_options (void)
if (!TARGET_80387)
target_flags &= ~MASK_FLOAT_RETURNS;
/* Use external vectorized library in vectorizing intrinsics. */
if (ix86_veclibabi_string)
{
if (strcmp (ix86_veclibabi_string, "acml") == 0)
ix86_veclib_handler = ix86_veclibabi_acml;
else
error ("unknown vectorization library ABI type (%s) for "
"-mveclibabi= switch", ix86_veclibabi_string);
}
if ((x86_accumulate_outgoing_args & ix86_tune_mask)
&& !(target_flags_explicit & MASK_ACCUMULATE_OUTGOING_ARGS)
&& !optimize_size)
@ -19934,33 +19948,122 @@ ix86_builtin_vectorized_function (unsigned int fn, tree type_out,
if (out_mode == DFmode && out_n == 2
&& in_mode == DFmode && in_n == 2)
return ix86_builtins[IX86_BUILTIN_SQRTPD];
return NULL_TREE;
break;
case BUILT_IN_SQRTF:
if (out_mode == SFmode && out_n == 4
&& in_mode == SFmode && in_n == 4)
return ix86_builtins[IX86_BUILTIN_SQRTPS];
return NULL_TREE;
break;
case BUILT_IN_LRINT:
if (out_mode == SImode && out_n == 4
&& in_mode == DFmode && in_n == 2)
return ix86_builtins[IX86_BUILTIN_VEC_PACK_SFIX];
return NULL_TREE;
break;
case BUILT_IN_LRINTF:
if (out_mode == SImode && out_n == 4
&& in_mode == SFmode && in_n == 4)
return ix86_builtins[IX86_BUILTIN_CVTPS2DQ];
return NULL_TREE;
break;
default:
;
}
/* Dispatch to a handler for a vectorization library. */
if (ix86_veclib_handler)
return (*ix86_veclib_handler)(fn, type_out, type_in);
return NULL_TREE;
}
/* Handler for an ACML-style interface to a library with vectorized
intrinsics. */
static tree
ix86_veclibabi_acml (enum built_in_function fn, tree type_out, tree type_in)
{
char name[20] = "__vr.._";
tree fntype, new_fndecl, args;
unsigned arity;
const char *bname;
enum machine_mode el_mode, in_mode;
int n, in_n;
/* The ACML is 64bits only and suitable for unsafe math only as
it does not correctly support parts of IEEE with the required
precision such as denormals. */
if (!TARGET_64BIT
|| !flag_unsafe_math_optimizations)
return NULL_TREE;
el_mode = TYPE_MODE (TREE_TYPE (type_out));
n = TYPE_VECTOR_SUBPARTS (type_out);
in_mode = TYPE_MODE (TREE_TYPE (type_in));
in_n = TYPE_VECTOR_SUBPARTS (type_in);
if (el_mode != in_mode
|| n != in_n)
return NULL_TREE;
switch (fn)
{
case BUILT_IN_SIN:
case BUILT_IN_COS:
case BUILT_IN_EXP:
case BUILT_IN_LOG:
case BUILT_IN_LOG2:
case BUILT_IN_LOG10:
name[4] = 'd';
name[5] = '2';
if (el_mode != DFmode
|| n != 2)
return NULL_TREE;
break;
case BUILT_IN_SINF:
case BUILT_IN_COSF:
case BUILT_IN_EXPF:
case BUILT_IN_POWF:
case BUILT_IN_LOGF:
case BUILT_IN_LOG2F:
case BUILT_IN_LOG10F:
name[4] = 's';
name[5] = '4';
if (el_mode != SFmode
|| n != 4)
return NULL_TREE;
break;
default:
return NULL_TREE;
}
bname = IDENTIFIER_POINTER (DECL_NAME (implicit_built_in_decls[fn]));
sprintf (name + 7, "%s", bname+10);
arity = 0;
for (args = DECL_ARGUMENTS (implicit_built_in_decls[fn]); args;
args = TREE_CHAIN (args))
arity++;
if (arity == 1)
fntype = build_function_type_list (type_out, type_in, NULL);
else
fntype = build_function_type_list (type_out, type_in, type_in, NULL);
/* Build a function declaration for the vectorized function. */
new_fndecl = build_decl (FUNCTION_DECL, get_identifier (name), fntype);
TREE_PUBLIC (new_fndecl) = 1;
DECL_EXTERNAL (new_fndecl) = 1;
DECL_IS_NOVOPS (new_fndecl) = 1;
TREE_READONLY (new_fndecl) = 1;
return new_fndecl;
}
/* Returns a decl of a function that implements conversion of the
input vector of type TYPE, or NULL_TREE if it is not available. */

View File

@ -182,6 +182,10 @@ mtune=
Target RejectNegative Joined Var(ix86_tune_string)
Schedule code for given CPU
mveclibabi=
Target RejectNegative Joined Var(ix86_veclibabi_string)
Vector library ABI to use
;; ISA support
m32

View File

@ -557,7 +557,7 @@ Objective-C and Objective-C++ Dialects}.
-mthreads -mno-align-stringops -minline-all-stringops @gol
-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
-m96bit-long-double -mregparm=@var{num} -msseregparm @gol
-mpc32 -mpc64 -mpc80 mstackrealign @gol
-mveclibabi=@var{type} -mpc32 -mpc64 -mpc80 -mstackrealign @gol
-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
-mcmodel=@var{code-model} @gol
-m32 -m64 -mlarge-data-threshold=@var{num}}
@ -10440,6 +10440,19 @@ vectorized variants RCPPS and RSQRTPS) instead of DIVSS and SQRTSS (and their
vectorized variants). These instructions will be generated only when
@option{-funsafe-math-optimizations} is enabled.
@item -mveclibabi=@var{type}
@opindex mveclibabi
Specifies the ABI type to use for vectorizing intrinsics using an
external library. Supported types are @code{acml} for the AMD
math core library style of interfacing. GCC will currently emit
calls to @code{__vrd2_sin}, @code{__vrd2_cos}, @code{__vrd2_exp},
@code{__vrd2_log}, @code{__vrd2_log2}, @code{__vrd2_log10},
@code{__vrs4_sinf}, @code{__vrs4_cosf}, @code{__vrs4_expf},
@code{__vrs4_logf}, @code{__vrs4_log2f}, @code{__vrs4_log10f}
and @code{__vrs4_powf} when using this type and @option{-ftree-vectorize}
is enabled. A ACML ABI compatible library will have to be specified
at link time.
@item -mpush-args
@itemx -mno-push-args
@opindex mpush-args

View File

@ -1,3 +1,7 @@
2007-08-30 Richard Guenther <rguenther@suse.de>
* gcc.target/i386/vectorize5.c: New testcase.
2007-08-30 Tobias Burnus <burnus@net-b.de>
PR fortran/33228

View File

@ -0,0 +1,17 @@
/* { dg-do compile } */
/* { dg-require-effective-target lp64 } */
/* { dg-options "-O2 -ftree-vectorize -mveclibabi=acml -ffast-math" } */
double x[256];
extern double sin(double);
void foo(void)
{
int i;
for (i=0; i<256; ++i)
x[i] = sin(x[i]);
}
/* { dg-final { scan-assembler "__vrd2_sin" } } */