On Fri, 11 Apr 2014, Richard Biener wrote: > > The following patch fixes the two related ICEs in the PRs by > properly implementing the recursion in graphite_can_represent_scev > to catch all CHRECs and reject remains with CHRECs. > > Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, will > commit shortly if that succeeds.
Bah, I have to recurse for the chrecs as well, of course. Otherwise all scop detection fails. Richard. 2014-04-11 Richard Biener <rguent...@suse.de> PR tree-optimization/59817 PR tree-optimization/60453 * graphite-scop-detection.c (graphite_can_represent_scev): Complete recursion to catch all CHRECs in the scalar evolution and restrict the predicate for the remains appropriately. * gfortran.dg/graphite/pr59817.f: New testcase. * gcc.dg/graphite/pr59817-1.c: Likewise. * gcc.dg/graphite/pr59817-2.c: Likewise. Index: gcc/testsuite/gfortran.dg/graphite/pr59817.f =================================================================== *** gcc/testsuite/gfortran.dg/graphite/pr59817.f (revision 0) --- gcc/testsuite/gfortran.dg/graphite/pr59817.f (working copy) *************** *** 0 **** --- 1,14 ---- + ! { dg-do compile } + ! { dg-options "-O2 -floop-interchange" } + SUBROUTINE PREPD(ICAST,ICAS,ICASX,ICAS1,ICAS2,NDET,NM,III,IMP, + * CASMIN) + LOGICAL CASMIN + DIMENSION ICAST(NDET,NM),IMP(NM) + IF(CASMIN) THEN + DO K=1,NDET + DO L=1,NM + IF(L.EQ.K-1) ICAST(K,L) = 1 + END DO + END DO + END IF + END SUBROUTINE Index: gcc/testsuite/gcc.dg/graphite/pr59817-2.c =================================================================== *** gcc/testsuite/gcc.dg/graphite/pr59817-2.c (revision 0) --- gcc/testsuite/gcc.dg/graphite/pr59817-2.c (working copy) *************** *** 0 **** --- 1,15 ---- + /* { dg-do compile } */ + /* { dg-options "-O2 -floop-interchange" } */ + + void + xl(void) + { + static int j3; + for (j3 = 0; j3 < 1; ++j3) { + static int f2; + static int w7; + short int b5; + int ok; + f2 = (b5 += ok) ? (w7 = 0): (w7 ? 0 : (f2 = ok)); + } + } Index: gcc/testsuite/gcc.dg/graphite/pr59817-1.c =================================================================== *** gcc/testsuite/gcc.dg/graphite/pr59817-1.c (revision 0) --- gcc/testsuite/gcc.dg/graphite/pr59817-1.c (working copy) *************** *** 0 **** --- 1,16 ---- + /* { dg-do compile } */ + /* { dg-options "-O2 -floop-interchange" } */ + + int kd; + + void + n2(void) + { + static int so; + static short int i5; + int wj; + int *il; + int *nk = &so; + for (wj = 0; wj < 2; ++wj) + *nk = ((i5 += *il) || kd ); + } Index: gcc/graphite-scop-detection.c =================================================================== *** gcc/graphite-scop-detection.c (revision 209292) --- gcc/graphite-scop-detection.c (working copy) *************** graphite_can_represent_scev (tree scev) *** 219,225 **** --- 219,232 ---- switch (TREE_CODE (scev)) { + case NEGATE_EXPR: + case BIT_NOT_EXPR: + CASE_CONVERT: + case NON_LVALUE_EXPR: + return graphite_can_represent_scev (TREE_OPERAND (scev, 0)); + case PLUS_EXPR: + case POINTER_PLUS_EXPR: case MINUS_EXPR: return graphite_can_represent_scev (TREE_OPERAND (scev, 0)) && graphite_can_represent_scev (TREE_OPERAND (scev, 1)); *************** graphite_can_represent_scev (tree scev) *** 241,253 **** if (!evolution_function_right_is_integer_cst (scev) || !graphite_can_represent_init (scev)) return false; default: break; } /* Only affine functions can be represented. */ ! if (!scev_is_linear_expression (scev)) return false; return true; --- 248,262 ---- if (!evolution_function_right_is_integer_cst (scev) || !graphite_can_represent_init (scev)) return false; + return graphite_can_represent_scev (CHREC_LEFT (scev)); default: break; } /* Only affine functions can be represented. */ ! if (tree_contains_chrecs (scev, NULL) ! || !scev_is_linear_expression (scev)) return false; return true;