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 up vectorizer cost model use of uninitialized value (PR tree-optimization/52210)


Hi!

The PR50912 changed vect_get_and_check_slp_defs dt from
array into scalar, which fails when calling vect_model_simple_cost
which looks at two array members.  I believe even 4.6 checked just
the first operand, as it called it when processing the first operand,
so IMHO this patch doesn't regress (the very incomplete) cost model
handling and doesn't introduce undefined behavior.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-02-13  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/52210
	* tree-vect-slp.c (vect_get_and_check_slp_defs): Call
	vect_model_simple_cost with two entry vect_def_type array instead
	of an address of dt.

	* gcc.dg/pr52210.c: New test.

--- gcc/tree-vect-slp.c.jj	2012-02-07 16:05:51.000000000 +0100
+++ gcc/tree-vect-slp.c	2012-02-13 10:14:28.017357662 +0100
@@ -321,10 +321,15 @@ vect_get_and_check_slp_defs (loop_vec_in
                 vect_model_store_cost (stmt_info, ncopies_for_cost, false,
                                         dt, slp_node);
 	      else
-	        /* Not memory operation (we don't call this function for
-		   loads).  */
-		vect_model_simple_cost (stmt_info, ncopies_for_cost, &dt,
-					slp_node);
+		{
+		  enum vect_def_type dts[2];
+		  dts[0] = dt;
+		  dts[1] = vect_uninitialized_def;
+		  /* Not memory operation (we don't call this function for
+		     loads).  */
+		  vect_model_simple_cost (stmt_info, ncopies_for_cost, dts,
+					  slp_node);
+		}
 	    }
 	}
       else
--- gcc/testsuite/gcc.dg/pr52210.c.jj	2012-02-13 10:27:46.692809216 +0100
+++ gcc/testsuite/gcc.dg/pr52210.c	2012-02-13 10:25:31.000000000 +0100
@@ -0,0 +1,12 @@
+/* PR tree-optimization/52210 */
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+void
+foo (long *x, long y, long z)
+{
+  long a = x[0];
+  long b = x[1];
+  x[0] = a & ~y;
+  x[1] = b & ~z;
+}

	Jakub


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