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][gomp4] Optimize expand_omp_for_static_chunk for chunk_size one


Jakub,

we're using expand_omp_for_static_chunk with a chunk_size of one to expand the
openacc loop construct.

This results in an inner and outer loop being generated, with the inner loop
having a trip count of one, which means that the inner loop can be simplified to
just the inner loop body. However, subsequent optimizations do not manage to do
this simplification.

This patch sets the loop exit condition to true if the chunk_size is one, to
ensure that the compiler will optimize away the inner loop.

OK for gomp4 branch?

Thanks,
- Tom
2014-07-25  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (expand_omp_for_static_chunk): Remove inner loop if
	chunk_size is one.

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b188e2d..5a73986 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -7345,9 +7345,14 @@ expand_omp_for_static_chunk (struct omp_region *region,
 	  stmt = gimple_build_assign (vback, t);
 	  gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
 
-	  t = build2 (fd->loop.cond_code, boolean_type_node,
-		      DECL_P (vback) && TREE_ADDRESSABLE (vback)
-		      ? t : vback, e);
+	  if (tree_int_cst_equal (fd->chunk_size, integer_one_node))
+	    t = build2 (EQ_EXPR, boolean_type_node,
+			build_int_cst (itype, 0),
+			build_int_cst (itype, 1));
+	  else
+	    t = build2 (fd->loop.cond_code, boolean_type_node,
+			DECL_P (vback) && TREE_ADDRESSABLE (vback)
+			? t : vback, e);
 	  gsi_insert_before (&gsi, gimple_build_cond_empty (t), GSI_SAME_STMT);
 	}
 

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