Patchwork Fix PR tree-optimization/46663

login
register
mail settings
Submitter Ira Rosen
Date Dec. 1, 2010, 10:13 a.m.
Message ID <OF729B076B.F629CF9D-ONC22577EC.00369AE5-C22577EC.00382161@il.ibm.com>
Download mbox | patch
Permalink /patch/73778/
State New
Headers show

Comments

Ira Rosen - Dec. 1, 2010, 10:13 a.m.
Hi,

This patch adds a check that FUNCTION_DECL exists for the call in
vectorizer power pattern recognition.
I am testing the patch for trunk on x86_64-suse-linux now.

The problem goes back to 4.0, how far back should I backport this fix?

Thanks,
Ira

ChangeLog:

	PR tree-optimization/46663
	* tree-vect-patterns.c (vect_recog_pow_pattern): Check that
	FUNCTION_DECL exists.

testsuite/ChangeLog:

	PR tree-optimization/46663
	* gcc.dg/vect/pr46663.c: New test.
Richard Guenther - Dec. 1, 2010, 11:58 a.m.
On Wed, Dec 1, 2010 at 11:13 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
>
> Hi,
>
> This patch adds a check that FUNCTION_DECL exists for the call in
> vectorizer power pattern recognition.
> I am testing the patch for trunk on x86_64-suse-linux now.
>
> The problem goes back to 4.0, how far back should I backport this fix?

Till 4.3, but the fix is not complete, it also needs

> +  if (fn == NULL_TREE
          || DECL_BUILT_IN_CLASS (fn) !=  BUILT_IN_NORMAL)
> +   return NULL;

otherwise it'll match target and non-builtins as well.

Richard.

> Thanks,
> Ira
>
> ChangeLog:
>
>        PR tree-optimization/46663
>        * tree-vect-patterns.c (vect_recog_pow_pattern): Check that
>        FUNCTION_DECL exists.
>
> testsuite/ChangeLog:
>
>        PR tree-optimization/46663
>        * gcc.dg/vect/pr46663.c: New test.
>
>
> Index: testsuite/gcc.dg/vect/pr46663.c
> ===================================================================
> --- testsuite/gcc.dg/vect/pr46663.c     (revision 0)
> +++ testsuite/gcc.dg/vect/pr46663.c     (revision 0)
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O -ftree-vectorize -fdump-tree-vect-details
> -fexceptions" } */
> +
> +typedef __attribute__ ((const)) int (*bart) (void);
> +
> +int foo (bart bar, int m)
> +{
> +  int i, j = 0;
> +  for (i = 0; i < m; i++)
> +    j += bar();
> +  return j;
> +}
> +
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> Index: tree-vect-patterns.c
> ===================================================================
> --- tree-vect-patterns.c        (revision 167324)
> +++ tree-vect-patterns.c        (working copy)
> @@ -472,6 +472,9 @@ vect_recog_pow_pattern (gimple last_stmt
>     return NULL;
>
>   fn = gimple_call_fndecl (last_stmt);
> +  if (fn == NULL_TREE)
> +   return NULL;
> +
>   switch (DECL_FUNCTION_CODE (fn))
>     {
>     case BUILT_IN_POWIF:
>
>
Ira Rosen - Dec. 1, 2010, 12:07 p.m.
Richard Guenther <richard.guenther@gmail.com> wrote on 01/12/2010 01:58:38
PM:
>
> On Wed, Dec 1, 2010 at 11:13 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
> >
> > Hi,
> >
> > This patch adds a check that FUNCTION_DECL exists for the call in
> > vectorizer power pattern recognition.
> > I am testing the patch for trunk on x86_64-suse-linux now.
> >
> > The problem goes back to 4.0, how far back should I backport this fix?
>
> Till 4.3, but the fix is not complete, it also needs
>
> > +  if (fn == NULL_TREE
>           || DECL_BUILT_IN_CLASS (fn) !=  BUILT_IN_NORMAL)
> > +   return NULL;
>
> otherwise it'll match target and non-builtins as well.

OK, I'll add this check.

Thanks,
Ira

>
> Richard.
>
> > Thanks,
> > Ira
> >
> > ChangeLog:
> >
> >        PR tree-optimization/46663
> >        * tree-vect-patterns.c (vect_recog_pow_pattern): Check that
> >        FUNCTION_DECL exists.
> >
> > testsuite/ChangeLog:
> >
> >        PR tree-optimization/46663
> >        * gcc.dg/vect/pr46663.c: New test.
> >
> >
> > Index: testsuite/gcc.dg/vect/pr46663.c
> > ===================================================================
> > --- testsuite/gcc.dg/vect/pr46663.c     (revision 0)
> > +++ testsuite/gcc.dg/vect/pr46663.c     (revision 0)
> > @@ -0,0 +1,14 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-O -ftree-vectorize -fdump-tree-vect-details
> > -fexceptions" } */
> > +
> > +typedef __attribute__ ((const)) int (*bart) (void);
> > +
> > +int foo (bart bar, int m)
> > +{
> > +  int i, j = 0;
> > +  for (i = 0; i < m; i++)
> > +    j += bar();
> > +  return j;
> > +}
> > +
> > +/* { dg-final { cleanup-tree-dump "vect" } } */
> > Index: tree-vect-patterns.c
> > ===================================================================
> > --- tree-vect-patterns.c        (revision 167324)
> > +++ tree-vect-patterns.c        (working copy)
> > @@ -472,6 +472,9 @@ vect_recog_pow_pattern (gimple last_stmt
> >     return NULL;
> >
> >   fn = gimple_call_fndecl (last_stmt);
> > +  if (fn == NULL_TREE)
> > +   return NULL;
> > +
> >   switch (DECL_FUNCTION_CODE (fn))
> >     {
> >     case BUILT_IN_POWIF:
> >
> >

Patch

Index: testsuite/gcc.dg/vect/pr46663.c
===================================================================
--- testsuite/gcc.dg/vect/pr46663.c     (revision 0)
+++ testsuite/gcc.dg/vect/pr46663.c     (revision 0)
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-vectorize -fdump-tree-vect-details
-fexceptions" } */
+
+typedef __attribute__ ((const)) int (*bart) (void);
+
+int foo (bart bar, int m)
+{
+  int i, j = 0;
+  for (i = 0; i < m; i++)
+    j += bar();
+  return j;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c        (revision 167324)
+++ tree-vect-patterns.c        (working copy)
@@ -472,6 +472,9 @@  vect_recog_pow_pattern (gimple last_stmt
     return NULL;

   fn = gimple_call_fndecl (last_stmt);
+  if (fn == NULL_TREE)
+   return NULL;
+
   switch (DECL_FUNCTION_CODE (fn))
     {
     case BUILT_IN_POWIF: