This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Do some vectorizer-friendly canonicalization before vectorization


On Wed, 22 Nov 2006, Dorit Nuzman wrote:

> 
> > Richard Guenther <rguenther@suse.de> wrote on 21/11/2006 13:21:56:
> >
> > >
> > > Ok, while the "pattern" is not exactly a pattern but only one
> > > instruction,
> >
> > it's a very simple pattern indeed...
> >
> > > here's the pattern variant.
> >
> > thanks!
> >
> 
> Hi Richard,
> 
> I didn't take a close enough look at the testcases you added, and missed
> the fact that they would fail on ppc:

The following passes for me on x86_64-unknown-linux-gnu.  Can you check
it works on ppc?

Thanks,
Richard.

2006-11-23  Richard Guenther  <rguenther@suse.de>

	* tree-vect-patterns.c (vect_recog_pow_pattern): Set
	type_in to scalar type in recognition of squaring.

	* gcc.dg/vect/vect.exp: Add support for -fno-math-errno tests.
	* gcc.dg/vect/vect-pow-1.c: Rename ...
	* gcc.dg/vect/fast-math-vect-pow-1.c: ... to this.  Use
	floats instead of doubles, check successful vectorization.
	* gcc.dg/vect/vect-pow-2.c: Rename ...
	* gcc.dg/vect/no-math-errno-vect-pow-1.c: .. to this.  Use
	floats instead of doubles.

Index: tree-vect-patterns.c
===================================================================
*** tree-vect-patterns.c	(revision 119115)
--- tree-vect-patterns.c	(working copy)
*************** vect_recog_pow_pattern (tree last_stmt, 
*** 466,472 ****
    /* We now have a pow or powi builtin function call with a constant
       exponent.  */
  
-   *type_in = get_vectype_for_scalar_type (TREE_TYPE (base));
    *type_out = NULL_TREE;
  
    /* Catch squaring.  */
--- 466,471 ----
*************** vect_recog_pow_pattern (tree last_stmt, 
*** 474,480 ****
         && tree_low_cst (exp, 0) == 2)
        || (TREE_CODE (exp) == REAL_CST
            && REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconst2)))
!     return build2 (MULT_EXPR, TREE_TYPE (base), base, base);
  
    /* Catch square root.  */
    if (TREE_CODE (exp) == REAL_CST
--- 473,482 ----
         && tree_low_cst (exp, 0) == 2)
        || (TREE_CODE (exp) == REAL_CST
            && REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconst2)))
!     {
!       *type_in = TREE_TYPE (base);
!       return build2 (MULT_EXPR, TREE_TYPE (base), base, base);
!     }
  
    /* Catch square root.  */
    if (TREE_CODE (exp) == REAL_CST
*************** vect_recog_pow_pattern (tree last_stmt, 
*** 482,487 ****
--- 484,490 ----
      {
        tree newfn = mathfn_built_in (TREE_TYPE (base), BUILT_IN_SQRT);
        tree newarglist = build_tree_list (NULL_TREE, base);
+       *type_in = get_vectype_for_scalar_type (TREE_TYPE (base));
        return build_function_call_expr (newfn, newarglist);
      }
  
Index: testsuite/gcc.dg/vect/vect-pow-1.c
===================================================================
*** testsuite/gcc.dg/vect/vect-pow-1.c	(revision 119115)
--- testsuite/gcc.dg/vect/vect-pow-1.c	(working copy)
***************
*** 1,14 ****
- /* { dg-do compile } */
- /* { dg-options "-O2 -ftree-vectorize -ffast-math -fdump-tree-vect-details" } */
- 
- double x[256];
- 
- void foo(void)
- {
-   int i;
-   for (i=0; i<256; ++i)
-     x[i] = x[i] * x[i];
- }
- 
- /* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */
- /* { dg-final { cleanup-tree-dump "vect" } } */
--- 0 ----
Index: testsuite/gcc.dg/vect/vect-pow-2.c
===================================================================
*** testsuite/gcc.dg/vect/vect-pow-2.c	(revision 119115)
--- testsuite/gcc.dg/vect/vect-pow-2.c	(working copy)
***************
*** 1,14 ****
- /* { dg-do compile } */
- /* { dg-options "-O2 -ftree-vectorize -fno-math-errno -fdump-tree-vect-details" } */
- 
- double x[256];
- 
- void foo(void)
- {
-   int i;
-   for (i=0; i<256; ++i)
-     x[i] = __builtin_pow (x[i], 0.5);
- }
- 
- /* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */
- /* { dg-final { cleanup-tree-dump "vect" } } */
--- 0 ----
Index: testsuite/gcc.dg/vect/fast-math-vect-pow-1.c
===================================================================
*** testsuite/gcc.dg/vect/fast-math-vect-pow-1.c	(revision 119115)
--- testsuite/gcc.dg/vect/fast-math-vect-pow-1.c	(working copy)
***************
*** 1,7 ****
  /* { dg-do compile } */
! /* { dg-options "-O2 -ftree-vectorize -ffast-math -fdump-tree-vect-details" } */
  
! double x[256];
  
  void foo(void)
  {
--- 1,7 ----
  /* { dg-do compile } */
! /* { dg-require-effective-target vect_float } */
  
! float x[256];
  
  void foo(void)
  {
*************** void foo(void)
*** 10,14 ****
      x[i] = x[i] * x[i];
  }
  
! /* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
--- 10,14 ----
      x[i] = x[i] * x[i];
  }
  
! /* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-math-errno-vect-pow-1.c
===================================================================
*** testsuite/gcc.dg/vect/no-math-errno-vect-pow-1.c	(revision 119115)
--- testsuite/gcc.dg/vect/no-math-errno-vect-pow-1.c	(working copy)
***************
*** 1,13 ****
  /* { dg-do compile } */
! /* { dg-options "-O2 -ftree-vectorize -fno-math-errno -fdump-tree-vect-details" } */
  
! double x[256];
  
  void foo(void)
  {
    int i;
    for (i=0; i<256; ++i)
!     x[i] = __builtin_pow (x[i], 0.5);
  }
  
  /* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */
--- 1,13 ----
  /* { dg-do compile } */
! /* { dg-require-effective-target vect_float } */
  
! float x[256];
  
  void foo(void)
  {
    int i;
    for (i=0; i<256; ++i)
!     x[i] = __builtin_powf (x[i], 0.5);
  }
  
  /* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */
Index: testsuite/gcc.dg/vect/vect.exp
===================================================================
*** testsuite/gcc.dg/vect/vect.exp	(revision 119115)
--- testsuite/gcc.dg/vect/vect.exp	(working copy)
*************** lappend DEFAULT_VECTCFLAGS "-ffast-math"
*** 97,102 ****
--- 97,108 ----
  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-vect*.\[cS\]]]  \
  	"" $DEFAULT_VECTCFLAGS
  
+ # -fno-math-errno tests
+ set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
+ lappend DEFAULT_VECTCFLAGS "-fno-math-errno"
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-math-errno-vect*.\[cS\]]]  \
+ 	"" $DEFAULT_VECTCFLAGS
+ 
  # -fwrapv tests
  set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
  lappend DEFAULT_VECTCFLAGS "-fwrapv"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]