[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    Re: [PATCH, i386]: Vectorize conversions for i386
From:       Tehila Meyzels <TEHILA () il ! ibm ! com>
Date:       2007-02-10 22:10:42
Message-ID: OF53B2448A.0D8C0223-ONC225727E.0079678D-C225727E.0079D4AA () il ! ibm ! com
[Download RAW message or body]

Dorit Nuzman/Haifa/IBM wrote on 09/02/2007 21:04:51:

> Uros Bizjak <ubizjak@gmail.com> wrote on 08/02/2007 16:50:23:
>
> > Hello!
> >
> > This patch implements conversions for i386 and x86_64 targets. Patch
>
> Cool, thanks!

I'd like to join the acknowledgement. Thanks, Uros!
>
> > builds on (yet uncommitted) patch that implements vectorized
conversions
> > infrastructure by Tehila Meyzels
> > (http://gcc.gnu.org/ml/gcc-patches/2007-02/msg00494.html).
> >
>
> I plan to commit it soonish. The vectorization-of-induction patch
> that I committed a couple of days ago actually exposed a couple of
> problems in this patch - I'm fixing it now - will commit the fixed
> version (and submit the fixes to the list) this weekend.

Dorit, thanks a lot for handling this.
Anything I can help with ?

Tehila.
>
> dorit
>
> > Patch was bootstrapped on x86_64-pc-linux-gnu and regression tested for

> > c,c++ and gfortran.
> >
> > This patch also includes two testcases from original patch, changed to
> > account for i386 and x86_64 targets and a testcase that checks
float-int
> > conversions.
> >
> > 2007-02-08  Uros Bizjak  <ubizjak@gmail.com>
> >
> >         * config/i386/i386.c (TARGET_VECTORIZE_BUILTIN_CONVERSION):
Define.
> >         (ix86_builtin_conversion): New function.
> >
> > testsuite/ChangeLog:
> >
> >         * gcc.dg/vect/vect-intfloat-conversion-1.c: Scan for vectorized
loop
> >         also for i?86-*-* and x86_64-*-* targets.
> >         * gcc.dg/vect/vect-intfloat-conversion-2.c: Ditto.
> >         * gcc.dg/vect/vect-floatint-conversion-1.c: New.
> >
> > Uros.
> >
> > Index: config/i386/i386.c
> > ===================================================================
> > --- config/i386/i386.c   (revision 121711)
> > +++ config/i386/i386.c   (working copy)
> > @@ -1516,6 +1516,7 @@
> >  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);
> > @@ -1580,8 +1581,11 @@
> >  #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
> > @@ -18056,6 +18060,40 @@
> >    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
> > Index: testsuite/gcc.dg/vect/vect-intfloat-conversion-1.c
> > ===================================================================
> > --- testsuite/gcc.dg/vect/vect-intfloat-conversion-1.c   (revision 0)
> > +++ testsuite/gcc.dg/vect/vect-intfloat-conversion-1.c   (revision 0)
> > @@ -0,0 +1,38 @@
> > +/* { dg-require-effective-target vect_int } */
> > +
> > +#include <stdarg.h>
> > +#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" } } */
> > Index: testsuite/gcc.dg/vect/vect-intfloat-conversion-2.c
> > ===================================================================
> > --- testsuite/gcc.dg/vect/vect-intfloat-conversion-2.c   (revision 0)
> > +++ testsuite/gcc.dg/vect/vect-intfloat-conversion-2.c   (revision 0)
> > @@ -0,0 +1,40 @@
> > +/* { dg-require-effective-target vect_int } */
> > +
> > +#include <stdarg.h>
> > +#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" } } */
> > Index: testsuite/gcc.dg/vect/vect-floatint-conversion-1.c
> > ===================================================================
> > --- testsuite/gcc.dg/vect/vect-floatint-conversion-1.c   (revision 0)
> > +++ testsuite/gcc.dg/vect/vect-floatint-conversion-1.c   (revision 0)
> > @@ -0,0 +1,40 @@
> > +/* { dg-require-effective-target vect_float } */
> > +
> > +#include <stdarg.h>
> > +#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" } } */

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic