Optimize expand_omp_for_static_chunk for chunk_size one

2015-08-24  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/65468
	* omp-low.c (expand_omp_for_static_chunk): Remove inner loop if
	chunk_size is one.

	* gcc.dg/gomp/static-chunk-size-one.c: New test.

	* testsuite/libgomp.c/static-chunk-size-one.c: New test.

From-SVN: r227124
This commit is contained in:
Tom de Vries 2015-08-24 13:14:17 +00:00 committed by Tom de Vries
parent 7373d132e1
commit 6be5c241bb
6 changed files with 65 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2015-08-24 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65468
* omp-low.c (expand_omp_for_static_chunk): Remove inner loop if
chunk_size is one.
2015-08-24 Nathan Sidwell <nathan@acm.org>
* config/nvptx/nvptx.c (walk_args_for_param): Revert previous

View File

@ -7204,6 +7204,11 @@ expand_omp_for_static_chunk (struct omp_region *region,
assign_stmt = gimple_build_assign (vback, t);
gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
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);

View File

@ -1,3 +1,8 @@
2015-08-24 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65468
* gcc.dg/gomp/static-chunk-size-one.c: New test.
2015-08-23 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR libfortran/54572

View File

@ -0,0 +1,18 @@
/* { dg-do compile } */
/* { dg-options "-fopenmp -O2 -fdump-tree-optimized -fno-tree-pre" } */
int
bar ()
{
int a = 0, i;
#pragma omp parallel for num_threads (3) reduction (+:a) schedule(static, 1)
for (i = 0; i < 10; i++)
a += i;
return a;
}
/* Two phis for reduction, one in loop header, one in loop exit. One phi for iv
in loop header. */
/* { dg-final { scan-tree-dump-times "PHI" 3 "optimized" } } */

View File

@ -1,3 +1,8 @@
2015-08-24 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65468
* testsuite/libgomp.c/static-chunk-size-one.c: New test.
2015-08-24 Joost VandeVondele <vondele@gnu.gcc.org>
PR libgomp/66761

View File

@ -0,0 +1,23 @@
extern void abort ();
int
bar ()
{
int a = 0, i;
#pragma omp parallel for num_threads (3) reduction (+:a) schedule(static, 1)
for (i = 0; i < 10; i++)
a += i;
return a;
}
int
main (void)
{
int res;
res = bar ();
if (res != 45)
abort ();
return 0;
}