public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR65494
@ 2015-03-23 12:42 Richard Biener
  2015-03-24  2:09 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2015-03-23 12:42 UTC (permalink / raw)
  To: gcc-patches


This fixes PR65494 - I don't remember why I re-allocated matches
before recursing into operands.  But that at least breaks backtracking.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2015-03-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/65494
	* tree-vect-slp.c (vect_build_slp_tree): Do not (re-)allocate
	matches here.
	(vect_analyze_slp_instance): But do that here, always and once.

	* gcc.dg/vect/pr65494.c: New testcase.

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	(revision 221532)
+++ gcc/tree-vect-slp.c	(working copy)
@@ -926,14 +926,9 @@ vect_build_slp_tree (loop_vec_info loop_
 		     bool *matches, unsigned *npermutes, unsigned *tree_size,
 		     unsigned max_tree_size)
 {
-  unsigned nops, i, this_npermutes = 0, this_tree_size = 0;
+  unsigned nops, i, this_tree_size = 0;
   gimple stmt;
 
-  if (!matches)
-    matches = XALLOCAVEC (bool, group_size);
-  if (!npermutes)
-    npermutes = &this_npermutes;
-
   matches[0] = false;
 
   stmt = SLP_TREE_SCALAR_STMTS (*node)[0];
@@ -1012,7 +1007,6 @@ vect_build_slp_tree (loop_vec_info loop_
 	  return false;
 	}
 
-      bool *matches = XALLOCAVEC (bool, group_size);
       if (vect_build_slp_tree (loop_vinfo, bb_vinfo, &child,
 			       group_size, max_nunits, loads,
 			       vectorization_factor, matches,
@@ -1637,9 +1631,11 @@ vect_analyze_slp_instance (loop_vec_info
   loads.create (group_size);
 
   /* Build the tree for the SLP instance.  */
+  bool *matches = XALLOCAVEC (bool, group_size);
+  unsigned npermutes = 0;
   if (vect_build_slp_tree (loop_vinfo, bb_vinfo, &node, group_size,
 			   &max_nunits, &loads,
-			   vectorization_factor, NULL, NULL, NULL,
+			   vectorization_factor, matches, &npermutes, NULL,
 			   max_tree_size))
     {
       /* Calculate the unrolling factor based on the smallest type.  */
Index: gcc/testsuite/gcc.dg/vect/pr65494.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr65494.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/pr65494.c	(working copy)
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast -funroll-loops" } */
+
+typedef unsigned char uchar;
+typedef struct rgb_ {uchar r; uchar g; uchar b;} rgb;
+#define N 512
+rgb in[N], out[N];
+float c[N];
+void foo(int n)
+{
+  int i, j;
+  for (i = 0; i < n; i++) //in and out are RGB byte arrays
+    {
+      float r = 0, g = 0, b = 0;
+      for (j = 0; j < 5; j++)
+	{
+	  r += (float)in[i + j].r * c[j];
+	  g += (float)in[i + j].g * c[j];
+	  b += (float)in[i + j].b * c[j];
+	}
+      out[i].r = (uchar)r;
+      out[i].g = (uchar)g;
+      out[i].b = (uchar)b;
+    }
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { vect_float && vect_intfloat_cvt } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix PR65494
  2015-03-23 12:42 [PATCH] Fix PR65494 Richard Biener
@ 2015-03-24  2:09 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2015-03-24  2:09 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

On Mon, Mar 23, 2015 at 5:42 AM, Richard Biener <rguenther@suse.de> wrote:
>
> This fixes PR65494 - I don't remember why I re-allocated matches
> before recursing into operands.  But that at least breaks backtracking.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
>
> Richard.
>
> 2015-03-23  Richard Biener  <rguenther@suse.de>
>
>         PR tree-optimization/65494
>         * tree-vect-slp.c (vect_build_slp_tree): Do not (re-)allocate
>         matches here.
>         (vect_analyze_slp_instance): But do that here, always and once.

This caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65533


-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-24  2:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 12:42 [PATCH] Fix PR65494 Richard Biener
2015-03-24  2:09 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).