From 1a67d2cd3c2704ca472bd845d384a7dbe065ac4f Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 2 Dec 2015 23:01:24 +0000 Subject: [PATCH] do not insert code outside the generated region on the testcase we used to generate code in the function entry bb_0, and that choked the cfg verifier. * graphite-isl-ast-to-gimple.c (copy_bb_and_scalar_dependences): Check that insertion point is still in the region. * gfortran.dg/graphite/id-26.f03: New. Co-Authored-By: Sebastian Pop From-SVN: r231211 --- gcc/ChangeLog | 6 + gcc/graphite-isl-ast-to-gimple.c | 1 + gcc/testsuite/ChangeLog | 5 + gcc/testsuite/gfortran.dg/graphite/id-26.f03 | 132 +++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/graphite/id-26.f03 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7fa28913165..d6ba2e83f78 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-12-02 Aditya Kumar + Sebastian Pop + + * graphite-isl-ast-to-gimple.c (copy_bb_and_scalar_dependences): Check + that insertion point is still in the region. + 2015-12-02 Aditya Kumar Sebastian Pop diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index 3139f302ff0..497b200f55a 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -2944,6 +2944,7 @@ translate_isl_ast_to_gimple::copy_bb_and_scalar_dependences (basic_block bb, /* If a corresponding merge-point was not found, then abort codegen. */ if (phi_bb->loop_father != loop_father + || !bb_in_sese_p (phi_bb, region->if_region->true_region->region) || !copy_cond_phi_nodes (bb, phi_bb, iv_map)) { codegen_error = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 299250b89ae..328f1ec27e0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-02 Aditya Kumar + Sebastian Pop + + * gfortran.dg/graphite/id-26.f03: New. + 2015-12-02 Jason Merrill * lib/g++.exp: Handle --stds= option. diff --git a/gcc/testsuite/gfortran.dg/graphite/id-26.f03 b/gcc/testsuite/gfortran.dg/graphite/id-26.f03 new file mode 100644 index 00000000000..c22cb169015 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/id-26.f03 @@ -0,0 +1,132 @@ +! { dg-options "-fcray-pointer -floop-nest-optimize" } + + use iso_c_binding, only : c_ptr, c_ptrdiff_t, c_loc + interface + subroutine foo (x, y, z, w) + use iso_c_binding, only : c_ptr + real, pointer :: x(:), y(:), w(:) + type(c_ptr) :: z + end subroutine + subroutine bar (x, y, z, w) + use iso_c_binding, only : c_ptr + real, pointer :: x(:), y(:), w(:) + type(c_ptr) :: z + end subroutine + subroutine baz (x, c) + real, pointer :: x(:) + real, allocatable :: c(:) + end subroutine + end interface + type dt + real, allocatable :: a(:) + end type + type (dt) :: b(64) + real, target :: a(4096+63) + real, pointer :: p(:), q(:), r(:), s(:) + real, allocatable :: c(:) + integer(c_ptrdiff_t) :: o + integer :: i + o = 64 - mod (loc (a), 64) + if (o == 64) o = 0 + o = o / sizeof(0.0) + p => a(o + 1:o + 1024) + q => a(o + 1025:o + 2048) + r => a(o + 2049:o + 3072) + s => a(o + 3073:o + 4096) + do i = 1, 1024 + p(i) = i + q(i) = i + r(i) = i + s(i) = i + end do + call foo (p, q, c_loc (r(1)), s) + do i = 1, 1024 + if (p(i) /= i * i + 3 * i + 2) call abort + p(i) = i + end do + call bar (p, q, c_loc (r(1)), s) + do i = 1, 1024 + if (p(i) /= i * i + 3 * i + 2) call abort + end do + ! Attempt to create 64-byte aligned allocatable + do i = 1, 64 + allocate (c(1023 + i)) + if (iand (loc (c(1)), 63) == 0) exit + deallocate (c) + allocate (b(i)%a(1023 + i)) + allocate (c(1023 + i)) + if (iand (loc (c(1)), 63) == 0) exit + deallocate (c) + end do + if (allocated (c)) then + do i = 1, 1024 + c(i) = 2 * i + end do + call baz (p, c) + do i = 1, 1024 + if (p(i) /= i * i + 5 * i + 2) call abort + end do + end if +end +subroutine foo (x, y, z, w) + use iso_c_binding, only : c_ptr, c_f_pointer + real, pointer :: x(:), y(:), w(:), p(:) + type(c_ptr) :: z + integer :: i + real :: pt(1024) + pointer (ip, pt) + ip = loc (w) +!$omp simd aligned (x, y : 64) + do i = 1, 1024 + x(i) = x(i) * y(i) + 2.0 + end do +!$omp simd aligned (x, z : 64) private (p) + do i = 1, 1024 + call c_f_pointer (z, p, shape=[1024]) + x(i) = x(i) + p(i) + end do +!$omp simd aligned (x, ip : 64) + do i = 1, 1024 + x(i) = x(i) + 2 * pt(i) + end do +!$omp end simd +end subroutine +subroutine bar (x, y, z, w) + use iso_c_binding, only : c_ptr, c_f_pointer + real, pointer :: x(:), y(:), w(:), a(:), b(:) + type(c_ptr) :: z, c + integer :: i + real :: pt(1024) + pointer (ip, pt) + ip = loc (w) + a => x + b => y + c = z +!$omp simd aligned (a, b : 64) + do i = 1, 1024 + a(i) = a(i) * b(i) + 2.0 + end do +!$omp simd aligned (a, c : 64) + do i = 1, 1024 + block + real, pointer :: p(:) + call c_f_pointer (c, p, shape=[1024]) + a(i) = a(i) + p(i) + end block + end do +!$omp simd aligned (a, ip : 64) + do i = 1, 1024 + a(i) = a(i) + 2 * pt(i) + end do +!$omp end simd +end subroutine +subroutine baz (x, c) + real, pointer :: x(:) + real, allocatable :: c(:) + integer :: i +!$omp simd aligned (x, c : 64) + do i = 1, 1024 + x(i) = x(i) + c(i) + end do +!$omp end simd +end subroutine baz -- 2.30.2