https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69728
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> --- A "simple" patch like the following seems to "work". Index: gcc/graphite-sese-to-poly.c =================================================================== --- gcc/graphite-sese-to-poly.c (revision 252920) +++ gcc/graphite-sese-to-poly.c (working copy) @@ -1043,6 +1043,13 @@ add_loop_schedule (__isl_take isl_schedu if (empty < 0 || empty) return empty < 0 ? isl_schedule_free (schedule) : schedule; + isl_union_set *domain = isl_schedule_get_domain (schedule); + if (isl_union_set_is_empty (domain)) + { + isl_union_set_free (domain); + return schedule; + } + isl_space *space = isl_set_get_space (iterators); int loop_index = isl_space_dim (space, isl_dim_set) - 1; @@ -1063,7 +1070,6 @@ add_loop_schedule (__isl_take isl_schedu prefix = isl_multi_aff_set_tuple_id (prefix, isl_dim_out, label); int n = isl_multi_aff_dim (prefix, isl_dim_in); - isl_union_set *domain = isl_schedule_get_domain (schedule); isl_multi_union_pw_aff *mupa = outer_projection_mupa (domain, n); mupa = isl_multi_union_pw_aff_apply_multi_aff (mupa, prefix); return isl_schedule_insert_partial_schedule (schedule, mupa); but it results in a bougs initial schedule: [scheduler] original ast: { for (int c0 = 0; c0 < -P_21; c0 += 1) { S_9(c0); if (P_21 + c0 <= -2) S_8(c0); } S_10(); } so the conditional loop ended up not being a loop. I believe in this case we are somehow confused by 'c' wrapping? niter is computed as -(unsigned int) (c.7_21 + 1). Can we really "handle" negating an unsigned value? static isl_pw_aff * extract_affine (scop_p s, tree e, __isl_take isl_space *space) { .. case NEGATE_EXPR: case BIT_NOT_EXPR: lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space)); rhs = extract_affine (s, integer_minus_one_node, space); res = isl_pw_aff_mul (lhs, rhs); break; so we do x * -1 for negate -- that looks ok. At least bogus for BIT_NOT_EXPR which is really -1 - x, not x * -1. Doesn't seem to handle any conversion to signed correctly either as it misses an appropriate 'wrap' operation (the existing one only works for unsigned). The offset argument in POINTER_PLUS_EXPR handling needs to be interpreted as signed. So for the ICE I now have the hackish Index: gcc/graphite-sese-to-poly.c =================================================================== --- gcc/graphite-sese-to-poly.c (revision 252920) +++ gcc/graphite-sese-to-poly.c (working copy) @@ -1030,6 +1035,8 @@ outer_projection_mupa (__isl_take isl_un return isl_multi_union_pw_aff_from_union_pw_multi_aff (data.res); } +static bool schedule_error; + /* Embed SCHEDULE in the constraints of the LOOP domain. */ static isl_schedule * @@ -1043,6 +1050,14 @@ add_loop_schedule (__isl_take isl_schedu if (empty < 0 || empty) return empty < 0 ? isl_schedule_free (schedule) : schedule; + isl_union_set *domain = isl_schedule_get_domain (schedule); + if (isl_union_set_is_empty (domain)) + { + schedule_error = true; + isl_union_set_free (domain); + return schedule; + } + isl_space *space = isl_set_get_space (iterators); int loop_index = isl_space_dim (space, isl_dim_set) - 1; @@ -1169,6 +1183,8 @@ build_schedule_loop_nest (scop_p scop, i static bool build_original_schedule (scop_p scop) { + schedule_error = false; + int i = 0; int n = scop->pbbs.length (); while (i < n) @@ -1183,6 +1199,14 @@ build_original_schedule (scop_p scop) scop->original_schedule = add_in_sequence (scop->original_schedule, s); } + if (schedule_error) + { + if (dump_file) + fprintf (dump_file, "[sese-to-poly] failed to build " + "original schedule\n"); + return false; + } + if (dump_file) { fprintf (dump_file, "[sese-to-poly] original schedule:\n");