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]

[patch] Fix PR tree-optimization/46663


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.


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:


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