------- Comment #4 from fxcoudert at gcc dot gnu dot org 2008-05-12 23:15 ------- Well, that one is subtle, but I think I found it: it's a TRUNC_DIV_EXPR that should be a FLOOR_DIV_EXPR in gfc_conv_loop_setup(). That simple fix makes all testcases in this PR run, except when -fbounds-check is added. To fix -fbounds-check, we need to correctly make all zero-sized section zero-sized, and not any-negative-sized, which is done by two appropriate MAX_EXPR. The complete patch is thus:
Index: trans-array.c =================================================================== --- trans-array.c (revision 135088) +++ trans-array.c (working copy) @@ -3083,6 +3083,8 @@ gfc_conv_ss_startstride (gfc_loopinfo * info->start[n]); tmp = fold_build2 (FLOOR_DIV_EXPR, gfc_array_index_type, tmp, info->stride[n]); + tmp = fold_build2 (MAX_EXPR, gfc_array_index_type, tmp, + build_int_cst (gfc_array_index_type, 0)); /* We remember the size of the first section, and check all the others against this. */ if (size[n]) @@ -3435,8 +3437,10 @@ gfc_conv_loop_setup (gfc_loopinfo * loop for (i = 0; i<=last; i++){...}; */ tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, loop->to[n], loop->from[n]); - tmp = fold_build2 (TRUNC_DIV_EXPR, gfc_array_index_type, + tmp = fold_build2 (FLOOR_DIV_EXPR, gfc_array_index_type, tmp, info->stride[n]); + tmp = fold_build2 (MAX_EXPR, gfc_array_index_type, tmp, + build_int_cst (gfc_array_index_type, -1)); loop->to[n] = gfc_evaluate_now (tmp, &loop->pre); /* Make the loop variable start at 0. */ loop->from[n] = gfc_index_zero_node; Bootstraps OK, I've started regtesting. -- fxcoudert at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2008-03-25 16:37:47 |2008-05-12 23:15:08 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35682