GRAPHITE has little testing coverage so only SPEC uncovered a latent issue in scop_detection::harmful_loop_in_region.
Gets us some more testcases. Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2018-01-22 Richard Biener <rguent...@suse.de> PR tree-optimization/83963 * graphite-scop-detection.c (scop_detection::harmful_loop_in_region): Properly terminate dominator walk when crossing the exit edge not when visiting its source block. * gfortran.dg/graphite/pr83963.f: New testcase. * gcc.dg/graphite/pr83963-2.c: Likewise. Index: gcc/graphite-scop-detection.c =================================================================== --- gcc/graphite-scop-detection.c (revision 256947) +++ gcc/graphite-scop-detection.c (working copy) @@ -677,10 +677,10 @@ scop_detection::harmful_loop_in_region ( if (!stmt_simple_for_scop_p (scop, gsi_stmt (gsi), bb)) return true; - if (bb != exit_bb) - for (basic_block dom = first_dom_son (CDI_DOMINATORS, bb); - dom; - dom = next_dom_son (CDI_DOMINATORS, dom)) + for (basic_block dom = first_dom_son (CDI_DOMINATORS, bb); + dom; + dom = next_dom_son (CDI_DOMINATORS, dom)) + if (dom != scop.exit->dest) worklist.safe_push (dom); } Index: gcc/testsuite/gfortran.dg/graphite/pr83963.f =================================================================== --- gcc/testsuite/gfortran.dg/graphite/pr83963.f (nonexistent) +++ gcc/testsuite/gfortran.dg/graphite/pr83963.f (working copy) @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-O -floop-nest-optimize" } + + SUBROUTINE DAVCI(NORB,NCOR,NCI,NA,NB, + * CI,MAXP,MAXW1, + * IHMCON,ISTRB,ISTRP,ISTAR,II) + DIMENSION EC(MAXP,MAXP),IWRK1(2*MAXW1) + EC(II,II) = 1.0D+00 + DO 1396 II=1,MAXP + DO 1398 JJ=1,II-1 + EC(II,JJ) = 0.0D+00 + 1398 CONTINUE + 1396 CONTINUE + IF (NA.EQ.NB) THEN + CALL RINAB0(SI1,SI2,NORB,NCOR,NCI,NA,NB,CI(1,IP),IACON1,IBCON1, + * IWRK1,IHMCON,ISTRB,ISTRP,ISTAR) + ENDIF + END Index: gcc/testsuite/gcc.dg/graphite/pr83963-2.c =================================================================== --- gcc/testsuite/gcc.dg/graphite/pr83963-2.c (nonexistent) +++ gcc/testsuite/gcc.dg/graphite/pr83963-2.c (working copy) @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -floop-nest-optimize" } */ + +int Chv_countBigEntries (int npivot, int pivotsizes[], int countflag, + double droptol, int nD) +{ + double absval ; + double *entries ; + int count; + int ii, jj, kinc, kk, kstart, stride ; + for ( ii = 0 ; ii < nD ; ii++ ) + { + kk = kstart ; + kinc = stride ; + for ( jj = 0 ; jj < ii ; jj++ ) + { + absval = __builtin_fabs(entries[kk]) ; + if ( absval >= droptol ) + count++ ; + kk += kinc ; + kinc -= 2 ; + } + kstart-- ; + } + return count; +}