From: Martin Liska Date: Wed, 20 Jul 2016 11:16:47 +0000 (+0200) Subject: Properly handly PHI stmts in later_of_the_two (PR X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=144530cf6352a55404e04bce3354e23d7c7c2d1d;p=gcc.git Properly handly PHI stmts in later_of_the_two (PR PR middle-end/71898 * graphite-isl-ast-to-gimple.c (later_of_the_two): Properly handly PHI stmts. * gfortran.dg/graphite/pr71898.f90: New test. From-SVN: r238513 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0b2eac8bccf..32e90ce66cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-07-20 Martin Liska + + PR middle-end/71898 + * graphite-isl-ast-to-gimple.c (later_of_the_two): + Properly handly PHI stmts. + 2016-07-20 Bin Cheng PR tree-optimization/71503 diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index fb9c8468ebc..07c88026cde 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -1305,6 +1305,18 @@ later_of_the_two (gimple_stmt_iterator gsi1, gimple_stmt_iterator gsi2) /* Find the iterator which is the latest. */ if (bb1 == bb2) { + gimple *stmt1 = gsi_stmt (gsi1); + gimple *stmt2 = gsi_stmt (gsi2); + + if (stmt1 != NULL && stmt2 != NULL) + { + bool is_phi1 = gimple_code (stmt1) == GIMPLE_PHI; + bool is_phi2 = gimple_code (stmt2) == GIMPLE_PHI; + + if (is_phi1 != is_phi2) + return is_phi1 ? gsi2 : gsi1; + } + /* For empty basic blocks gsis point to the end of the sequence. Since there is no operator== defined for gimple_stmt_iterator and for gsis not pointing to a valid statement gsi_next would assert. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e631db95057..41b09e268db 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-07-20 Martin Liska + + * gfortran.dg/graphite/pr71898.f90: New test. + 2016-07-20 Bin Cheng PR tree-optimization/71503 diff --git a/gcc/testsuite/gfortran.dg/graphite/pr71898.f90 b/gcc/testsuite/gfortran.dg/graphite/pr71898.f90 new file mode 100644 index 00000000000..01d6852cf3c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/pr71898.f90 @@ -0,0 +1,45 @@ +! { dg-do compile } +! { dg-options "-floop-nest-optimize -O1" } + +MODULE d3_poly + INTEGER, PUBLIC, PARAMETER :: max_grad2=5 + INTEGER, PUBLIC, PARAMETER :: max_grad3=3 + INTEGER, PUBLIC, PARAMETER :: cached_dim2=(max_grad2+1)*(max_grad2+2)/2 + INTEGER, PUBLIC, PARAMETER :: cached_dim3=(max_grad3+1)*(max_grad3+2)*(max_grad3+3)/6 + INTEGER, SAVE, DIMENSION(3,cached_dim3) :: a_mono_exp3 + INTEGER, SAVE, DIMENSION(cached_dim2,cached_dim2) :: a_mono_mult2 + INTEGER, SAVE, DIMENSION(cached_dim3,cached_dim3) :: a_mono_mult3 + INTEGER, SAVE, DIMENSION(4,cached_dim3) :: a_mono_mult3a +CONTAINS +SUBROUTINE init_d3_poly_module() + INTEGER :: grad, i, ii, ij, j, subG + INTEGER, DIMENSION(3) :: monoRes3 + DO grad=0,max_grad2 + DO i=grad,0,-1 + DO j=grad-i,0,-1 + END DO + END DO + END DO + DO ii=1,cached_dim3 + DO ij=ii,cached_dim2 + a_mono_mult2(ij,ii)=a_mono_mult2(ii,ij) + END DO + END DO + DO ii=1,cached_dim3 + DO ij=ii,cached_dim3 + monoRes3=a_mono_exp3(:,ii)+a_mono_exp3(:,ij) + a_mono_mult3(ii,ij)=mono_index3(monoRes3(1),monoRes3(2),monoRes3(3))+1 + a_mono_mult3(ij,ii)=a_mono_mult3(ii,ij) + END DO + END DO + DO i=1,cached_dim3 + DO j=1,4 + a_mono_mult3a(j,i)=a_mono_mult3(j,i) + END DO + END DO +END SUBROUTINE +PURE FUNCTION mono_index3(i,j,k) RESULT(res) + INTEGER, INTENT(in) :: i, j, k + res=grad*(grad+1)*(grad+2)/6+(sgrad)*(sgrad+1)/2+k +END FUNCTION +END MODULE d3_poly