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]

[committed] Fix two simd vectorization issues (PR tree-optimization/58472)


Hi!

I've committed the following patch to trunk (except for the testcase, which
went to gomp-4_0-branch only), the tree-vect-stmts.c hunks as obvious,
inv_p has been used uninitialized for simd lane accesses, the omp-low.c
change to fix -Wuninitialized on simd code.

2013-09-19  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/58472
	* tree-vect-stmts.c (vectorizable_store, vectorizable_load): For
	simd_lane_access set inv_p = false.
	* omp-low.c (lower_rec_input_clauses): Set TREE_NO_WARNING on
	the simduid magic VAR_DECL.

	* c-c++-common/gomp/pr58472.c: New test.

--- gcc/tree-vect-stmts.c.jj	2013-09-18 12:17:55.000000000 +0200
+++ gcc/tree-vect-stmts.c	2013-09-19 14:17:00.771484495 +0200
@@ -4182,6 +4182,7 @@ vectorizable_store (gimple stmt, gimple_
 	      dataref_ptr = unshare_expr (DR_BASE_ADDRESS (first_dr));
 	      dataref_offset = build_int_cst (reference_alias_ptr_type
 					      (DR_REF (first_dr)), 0);
+	      inv_p = false;
 	    }
 	  else
 	    dataref_ptr
@@ -5077,6 +5078,7 @@ vectorizable_load (gimple stmt, gimple_s
 	      dataref_ptr = unshare_expr (DR_BASE_ADDRESS (first_dr));
 	      dataref_offset = build_int_cst (reference_alias_ptr_type
 					      (DR_REF (first_dr)), 0);
+	      inv_p = false;
 	    }
 	  else
 	    dataref_ptr
--- gcc/omp-low.c.jj	2013-09-19 12:59:49.000000000 +0200
+++ gcc/omp-low.c	2013-09-19 18:23:27.860618153 +0200
@@ -3460,6 +3460,9 @@ lower_rec_input_clauses (tree clauses, g
   if (lane)
     {
       tree uid = create_tmp_var (ptr_type_node, "simduid");
+      /* Don't want uninit warnings on simduid, it is always uninitialized,
+	 but we use it not for the value, but for the DECL_UID only.  */
+      TREE_NO_WARNING (uid) = 1;
       gimple g
 	= gimple_build_call_internal (IFN_GOMP_SIMD_LANE, 1, uid);
       gimple_call_set_lhs (g, lane);
--- gcc/testsuite/c-c++-common/gomp/pr58472.c.jj	2013-09-19 18:47:56.309209103 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr58472.c	2013-09-19 18:26:24.000000000 +0200
@@ -0,0 +1,16 @@
+/* PR tree-optimization/58472 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall -fopenmp" } */
+
+float a[1024], b[1024];
+
+float
+foo ()
+{
+  float s = 0.f;
+  unsigned int i;
+#pragma omp simd reduction(+:s)
+  for (i = 0; i < 1024; ++i)
+    s += a[i] * b[i];
+  return s;
+}

	Jakub


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