Patchwork Fix PR tree-optimization/46663

login
register
mail settings
Submitter Ira Rosen
Date Dec. 2, 2010, 11:47 a.m.
Message ID <OF0FB9D5BA.4380E619-ONC22577ED.002F99E6-C22577ED.0040CA4F@il.ibm.com>
Download mbox | patch
Permalink /patch/73956/
State New
Headers show

Comments

Ira Rosen - Dec. 2, 2010, 11:47 a.m.
gcc-patches-owner@gcc.gnu.org wrote on 01/12/2010 02:07:30 PM:

> > 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.
>

Committed to mainline after bootstrapping on powerpc64-suse-linux and
testing on x86_64-suse-linux.
Now testing for 4.5, 4.4, and 4.3 on x86_64-suse-linux. OK once the testing
completes?

Thanks,
Ira

ChangeLog (for all versions):

	PR tree-optimization/46663
	* tree-vect-patterns.c (vect_recog_pow_pattern): Check that
	FUNCTION_DECL exists and that it's a builtin.

testsuite/ChangeLog:

	PR tree-optimization/46663
	* gcc.dg/vect/pr46663.c: New test.


4.6 patch:
Richard Guenther - Dec. 2, 2010, 1:48 p.m.
On Thu, Dec 2, 2010 at 12:47 PM, Ira Rosen <IRAR@il.ibm.com> wrote:
>
>
> gcc-patches-owner@gcc.gnu.org wrote on 01/12/2010 02:07:30 PM:
>
>> > 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.
>>
>
> Committed to mainline after bootstrapping on powerpc64-suse-linux and
> testing on x86_64-suse-linux.
> Now testing for 4.5, 4.4, and 4.3 on x86_64-suse-linux. OK once the testing
> completes?

Ok.

Thanks,
Richard.

> Thanks,
> Ira
>
> ChangeLog (for all versions):
>
>        PR tree-optimization/46663
>        * tree-vect-patterns.c (vect_recog_pow_pattern): Check that
>        FUNCTION_DECL exists and that it's a builtin.
>
> testsuite/ChangeLog:
>
>        PR tree-optimization/46663
>        * gcc.dg/vect/pr46663.c: New test.
>
>
> 4.6 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 || DECL_BUILT_IN_CLASS (fn) != BUILT_IN_NORMAL)
> +   return NULL;
> +
>   switch (DECL_FUNCTION_CODE (fn))
>     {
>     case BUILT_IN_POWIF:
>
>
> 4.5 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 167365)
> +++ tree-vect-patterns.c        (working copy)
> @@ -469,6 +469,9 @@ vect_recog_pow_pattern (gimple last_stmt
>     return NULL;
>
>   fn = gimple_call_fndecl (last_stmt);
> +  if (fn == NULL_TREE || DECL_BUILT_IN_CLASS (fn) != BUILT_IN_NORMAL)
> +   return NULL;
> +
>   switch (DECL_FUNCTION_CODE (fn))
>     {
>     case BUILT_IN_POWIF:
>
>
> 4.4 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 167365)
> +++ tree-vect-patterns.c        (working copy)
> @@ -475,6 +475,9 @@ vect_recog_pow_pattern (gimple last_stmt
>   type = gimple_expr_type (last_stmt);
>
>   fn = gimple_call_fndecl (last_stmt);
> +  if (fn == NULL_TREE || DECL_BUILT_IN_CLASS (fn) != BUILT_IN_NORMAL)
> +    return NULL;
> +
>   switch (DECL_FUNCTION_CODE (fn))
>     {
>     case BUILT_IN_POWIF:
>
>
> 4.3 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 167365)
> +++ tree-vect-patterns.c        (working copy)
> @@ -463,6 +463,9 @@ vect_recog_pow_pattern (tree last_stmt,
>     return NULL_TREE;
>
>   fn = get_callee_fndecl (expr);
> +  if (fn == NULL_TREE || DECL_BUILT_IN_CLASS (fn) != BUILT_IN_NORMAL)
> +    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 || DECL_BUILT_IN_CLASS (fn) != BUILT_IN_NORMAL)
+   return NULL;
+
   switch (DECL_FUNCTION_CODE (fn))
     {
     case BUILT_IN_POWIF:


4.5 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 167365)
+++ tree-vect-patterns.c        (working copy)
@@ -469,6 +469,9 @@  vect_recog_pow_pattern (gimple last_stmt
     return NULL;

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


4.4 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 167365)
+++ tree-vect-patterns.c        (working copy)
@@ -475,6 +475,9 @@  vect_recog_pow_pattern (gimple last_stmt
   type = gimple_expr_type (last_stmt);

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


4.3 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 167365)
+++ tree-vect-patterns.c        (working copy)
@@ -463,6 +463,9 @@  vect_recog_pow_pattern (tree last_stmt,
     return NULL_TREE;

   fn = get_callee_fndecl (expr);
+  if (fn == NULL_TREE || DECL_BUILT_IN_CLASS (fn) != BUILT_IN_NORMAL)
+    return NULL;
+
   switch (DECL_FUNCTION_CODE (fn))
     {
     case BUILT_IN_POWIF: