Insert new bound in try_transform_to_exit_first_loop_alt

2015-07-10  Tom de Vries  <tom@codesourcery.com>

	* tree-parloops.c (try_transform_to_exit_first_loop_alt): If not found,
	insert nit + 1 bound.

	* testsuite/libgomp.fortran/parloops-exit-first-loop-alt-2.f95: New test.
	* testsuite/libgomp.fortran/parloops-exit-first-loop-alt.f95: New test.

	* gfortran.dg/parloops-exit-first-loop-alt-2.f95: New test.
	* gfortran.dg/parloops-exit-first-loop-alt.f95: New test.

From-SVN: r225655
This commit is contained in:
Tom de Vries 2015-07-10 08:25:18 +00:00 committed by Tom de Vries
parent 094fe02336
commit 9f620bf1ea
8 changed files with 156 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2015-07-10 Tom de Vries <tom@codesourcery.com>
* tree-parloops.c (try_transform_to_exit_first_loop_alt): If not found,
insert nit + 1 bound.
2015-07-10 Richard Biener <rguenther@suse.de>
* tree-if-conv.c (if_convertible_gimple_assign_stmt_p):

View File

@ -1,3 +1,8 @@
2015-07-10 Tom de Vries <tom@codesourcery.com>
* gfortran.dg/parloops-exit-first-loop-alt-2.f95: New test.
* gfortran.dg/parloops-exit-first-loop-alt.f95: New test.
2015-07-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/66823

View File

@ -0,0 +1,24 @@
! { dg-additional-options "-O2" }
! { dg-require-effective-target pthread }
! { dg-additional-options "-ftree-parallelize-loops=2" }
! { dg-additional-options "-fdump-tree-parloops" }
! Constant bound, vector addition.
subroutine foo ()
integer, parameter :: n = 1000
integer, dimension (0:n-1) :: a, b, c
common a, b, c
integer :: ii
do ii = 0, n - 1
c(ii) = a(ii) + b(ii) + 25
end do
end subroutine foo
! Three times plus 25:
! - once in f._loopfn.0
! - once in the parallel
! - once in the low iteration count loop
! Crucially, none for a peeled off last iteration following the parallel.
! { dg-final { scan-tree-dump-times "(?n) \\+ 25;" 3 "parloops" } }

View File

@ -0,0 +1,25 @@
! { dg-additional-options "-O2" }
! { dg-require-effective-target pthread }
! { dg-additional-options "-ftree-parallelize-loops=2" }
! { dg-additional-options "-fdump-tree-parloops" }
! Variable bound, vector addition.
subroutine foo (nr)
integer, intent(in) :: nr
integer, parameter :: n = 1000
integer, dimension (0:n-1) :: a, b, c
common a, b, c
integer :: ii
do ii = 0, nr - 1
c(ii) = a(ii) + b(ii) + 25
end do
end subroutine foo
! Three times plus 25:
! - once in f._loopfn.0
! - once in the parallel
! - once in the low iteration count loop
! Crucially, none for a peeled off last iteration following the parallel.
! { dg-final { scan-tree-dump-times "(?n) \\+ 25;" 3 "parloops" } }

View File

@ -1828,8 +1828,18 @@ try_transform_to_exit_first_loop_alt (struct loop *loop,
alt_bound = op1;
}
/* If not found, insert nit + 1. */
if (alt_bound == NULL_TREE)
return false;
{
alt_bound = fold_build2 (PLUS_EXPR, nit_type, nit,
build_int_cst_type (nit_type, 1));
gimple_stmt_iterator gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
alt_bound
= force_gimple_operand_gsi (&gsi, alt_bound, true, NULL_TREE, false,
GSI_CONTINUE_LINKING);
}
transform_to_exit_first_loop_alt (loop, reduction_list, alt_bound);
return true;

View File

@ -1,3 +1,8 @@
2015-07-10 Tom de Vries <tom@codesourcery.com>
* testsuite/libgomp.fortran/parloops-exit-first-loop-alt-2.f95: New test.
* testsuite/libgomp.fortran/parloops-exit-first-loop-alt.f95: New test.
2015-07-08 Thomas Schwinge <thomas@codesourcery.com>
PR libgomp/65099

View File

@ -0,0 +1,40 @@
! { dg-do run }
! { dg-additional-options "-O2" }
! { dg-additional-options "-ftree-parallelize-loops=2" }
! Constant bound, vector addition.
subroutine foo ()
integer, parameter :: n = 1000
integer, dimension (0:n-1) :: a, b, c
common a, b, c
integer :: ii
do ii = 0, n - 1
c(ii) = a(ii) + b(ii)
end do
end subroutine foo
program main
integer, parameter :: n = 1000
integer, parameter :: distrib = 10
integer, dimension (0:n-1) :: a, b, c
common a, b, c
integer :: i, j, k
do j = 0, ((n / distrib) -1)
do i = 0, distrib - 1
k = i + (distrib * j)
a(k) = k
b(k) = MODULO ((k * 3), 7)
c(k) = k * 2;
end do
end do
call foo ()
do i = 0, n - 1
if (c(i) .ne. (i + MODULO ((i * 3), 7))) call abort
end do
end program

View File

@ -0,0 +1,41 @@
! { dg-do run }
! { dg-additional-options "-O2" }
! { dg-additional-options "-ftree-parallelize-loops=2" }
! Variable bound, vector addition.
subroutine foo (nr)
integer, intent(in) :: nr
integer, parameter :: n = 1000
integer, dimension (0:n-1) :: a, b, c
common a, b, c
integer :: ii
do ii = 0, nr - 1
c(ii) = a(ii) + b(ii)
end do
end subroutine foo
program main
integer, parameter :: n = 1000
integer, parameter :: distrib = 10
integer, dimension (0:n-1) :: a, b, c
common a, b, c
integer :: i, j, k
do j = 0, ((n / distrib) -1)
do i = 0, distrib - 1
k = i + (distrib * j)
a(k) = k
b(k) = MODULO ((k * 3), 7)
c(k) = k * 2;
end do
end do
call foo (n)
do i = 0, n - 1
if (c(i) .ne. (i + MODULO ((i * 3), 7))) call abort
end do
end program