From 647e9f063f0f3df989bf6b81e5416009fa73822a Mon Sep 17 00:00:00 2001 From: uros Date: Sun, 11 Feb 2007 19:48:07 +0000 Subject: [PATCH] * config/i386/i386.c (TARGET_VECTORIZE_BUILTIN_CONVERSION): Define. (ix86_builtin_conversion): New function. testsuite/ChangeLog: * gcc.dg/vect/vect-intfloat-conversion-1.c: Loop gets vectorized on i?86 and x86_64. * gcc.dg/vect/vect-intfloat-conversion-2.c: Ditto. * gcc.dg/vect/vect-floatint-conversion-1.c: New. * gcc.dg/vect/vect-93.c: Another loop gets vectorized on i?86 and x86_64. * gcc.dg/vect/vect-113.c: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121820 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++ gcc/config/i386/i386.c | 38 ++++++++++++++++++++ gcc/testsuite/ChangeLog | 16 +++++++-- gcc/testsuite/gcc.dg/vect/vect-113.c | 2 +- gcc/testsuite/gcc.dg/vect/vect-93.c | 6 ++-- .../gcc.dg/vect/vect-floatint-conversion-1.c | 40 ++++++++++++++++++++++ .../gcc.dg/vect/vect-intfloat-conversion-1.c | 38 ++++++++++++++++++++ .../gcc.dg/vect/vect-intfloat-conversion-2.c | 40 ++++++++++++++++++++++ 8 files changed, 178 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-floatint-conversion-1.c create mode 100644 gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-1.c create mode 100644 gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ce0f2ae..bd05c7f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2007-02-11 Uros Bizjak + + * config/i386/i386.c (TARGET_VECTORIZE_BUILTIN_CONVERSION): Define. + (ix86_builtin_conversion): New function. + 2007-02-06 Mark Mitchell PR target/29487 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2dbfe47..a052ea2 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -1514,6 +1514,7 @@ static bool ix86_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, static void ix86_init_builtins (void); static rtx ix86_expand_builtin (tree, rtx, rtx, enum machine_mode, int); static tree ix86_builtin_vectorized_function (enum built_in_function, tree, tree); +static tree ix86_builtin_conversion (enum tree_code, tree); static const char *ix86_mangle_fundamental_type (tree); static tree ix86_stack_protect_fail (void); static rtx ix86_internal_arg_pointer (void); @@ -1581,8 +1582,11 @@ static section *x86_64_elf_select_section (tree decl, int reloc, #define TARGET_INIT_BUILTINS ix86_init_builtins #undef TARGET_EXPAND_BUILTIN #define TARGET_EXPAND_BUILTIN ix86_expand_builtin + #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION ix86_builtin_vectorized_function +#undef TARGET_VECTORIZE_BUILTIN_CONVERSION +#define TARGET_VECTORIZE_BUILTIN_CONVERSION ix86_builtin_conversion #undef TARGET_ASM_FUNCTION_EPILOGUE #define TARGET_ASM_FUNCTION_EPILOGUE ix86_output_function_epilogue @@ -18268,6 +18272,40 @@ ix86_builtin_vectorized_function (enum built_in_function fn, tree type_out, return NULL_TREE; } +/* Returns a decl of a function that implements conversion of the + input vector of type TYPE, or NULL_TREE if it is not available. */ + +static tree +ix86_builtin_conversion (enum tree_code code, tree type) +{ + if (TREE_CODE (type) != VECTOR_TYPE) + return NULL_TREE; + + switch (code) + { + case FLOAT_EXPR: + switch (TYPE_MODE (type)) + { + case V4SImode: + return ix86_builtins[IX86_BUILTIN_CVTDQ2PS]; + default: + return NULL_TREE; + } + + case FIX_TRUNC_EXPR: + switch (TYPE_MODE (type)) + { + case V4SFmode: + return ix86_builtins[IX86_BUILTIN_CVTTPS2DQ]; + default: + return NULL_TREE; + } + default: + return NULL_TREE; + + } +} + /* Store OPERAND to the memory after reload is completed. This means that we can't easily use assign_stack_local. */ rtx diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f38b0c..b03e9c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2007-02-11 Uros Bizjak + + * gcc.dg/vect/vect-intfloat-conversion-1.c: Loop gets vectorized + on i?86 and x86_64. + * gcc.dg/vect/vect-intfloat-conversion-2.c: Ditto. + * gcc.dg/vect/vect-floatint-conversion-1.c: New. + * gcc.dg/vect/vect-93.c: Another loop gets vectorized + on i?86 and x86_64. + * gcc.dg/vect/vect-113.c: Ditto. + 2007-02-06 Mark Mitchell PR c++/29487 @@ -8,9 +18,9 @@ 2007-02-11 Tehila Meyzels Dorit Nuzman - * gcc.dg/vect/vect-intfloat-conversion.c-1: New test. - * gcc.dg/vect/vect-intfloat-conversion.c-2: New test. - * gcc.dg/vect/vect-93.c: Another loop gets vectorized on powerpc. + * gcc.dg/vect/vect-intfloat-conversion-1.c: New test. + * gcc.dg/vect/vect-intfloat-conversion-1.c: New test. + * gcc.dg/vect/vect-93.c: Another loop gets vectorized on powerpc. * gcc.dg/vect/vect-113.c: Likewise. * gcc.dg/vect/vect-iv-11.c: A loop gets vectorized. diff --git a/gcc/testsuite/gcc.dg/vect/vect-113.c b/gcc/testsuite/gcc.dg/vect/vect-113.c index 3b3d1db..f5d6b4a 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-113.c +++ b/gcc/testsuite/gcc.dg/vect/vect-113.c @@ -32,5 +32,5 @@ int main (void) return main1 (); } -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-93.c b/gcc/testsuite/gcc.dg/vect/vect-93.c index a084922..5c8b0d0 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-93.c +++ b/gcc/testsuite/gcc.dg/vect/vect-93.c @@ -67,15 +67,15 @@ int main (void) /* 2 loops vectorized in main1, 2 loops vectorized in main: the first loop in main requires vectorization of conversions, - the second loop in main requires vectorization of misaliged load: */ + the second loop in main requires vectorization of misaliged load. */ /* main && main1 together: */ -/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" { target powerpc*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { target vect_no_align } } } */ /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 3 "vect" { xfail vect_no_align } } } */ /* in main1: */ -/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target {! powerpc*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target !powerpc*-*-* !i?86-*-* !x86_64-*-* } } } */ /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect_no_align } } } */ /* in main: */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-floatint-conversion-1.c b/gcc/testsuite/gcc.dg/vect/vect-floatint-conversion-1.c new file mode 100644 index 0000000..95ffc68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-floatint-conversion-1.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int +main1 () +{ + int i; + float fb[N] = {0.4,3.5,6.6,9.4,12.5,15.6,18.4,21.5,24.6,27.4,30.5,33.6,36.4,39.5,42.6,45.4,0.5,3.6,6.4,9.5,12.6,15.4,18.5,21.6,24.4,27.5,30.6,33.4,36.5,39.6,42.4,45.5}; + int ia[N]; + + /* float -> int */ + for (i = 0; i < N; i++) + { + ia[i] = (int) fb[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != (int) fb[i]) + abort (); + } + + return 0; +} + +int +main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-1.c b/gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-1.c new file mode 100644 index 0000000..1369f2b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-1.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int main1 () +{ + int i; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float fa[N]; + + /* int -> float */ + for (i = 0; i < N; i++) + { + fa[i] = (float) ib[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (fa[i] != (float) ib[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-2.c b/gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-2.c new file mode 100644 index 0000000..c189e54 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-intfloat-conversion-2.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int main1 () +{ + int i; + int int_arr[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float float_arr[N]; + char char_arr[N]; + + for (i = 0; i < N; i++){ + float_arr[i] = (float) int_arr[i]; + char_arr[i] = 0; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (float_arr[i] != (float) int_arr[i]) + abort (); + if (char_arr[i] != 0) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ -- 2.7.4