This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] PR fortran/53732


Hello,

Revision 180898:
http://gcc.gnu.org/viewcvs?view=revision&revision=180898
introduced at the end of gfc_add_loop_ss_code some self recursive calls to handle reductions' loops (like in sum for example).
However, as gfc_add_loop_ss_code already calls itself to handle scalar and vector subscripts, the new calls had to be disabled if there was such a subscript, as in that case the reduction(s) would have been handled from within the subscript call.
Back then, I didn't pay attention, however, to the fact that the subscript flag was set to true in all the subscript calls, so the reductions are then handled with subscript set to true, which introduces an unwanted conversion to gfc_array_index_type and the failure leading to the PR.


The patch below (which is the one posted on bugzilla) disables reduction handling if subscript is true, so that the reductions are handled from the outer call instead of from the subscript call.
I have finally convinced myself that it is always right, as if there is a reduction in a subscript, gfc_add_loop_ss_code will call gfc_conv_expr_descriptor which will create a temporary, and the reduction will be handled separatedly in a new loop initializing the temporary.


Regression tested on x86_64-unknown-freebsd9.0.
OK for trunk/4.7?

Mikael

Attachment: pr53732_v1.CL
Description: Text document

diff --git a/trans-array.c b/trans-array.c
index f135af1..d289ac3 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -2398,7 +2398,6 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
   gfc_ss_info *ss_info;
   gfc_array_info *info;
   gfc_expr *expr;
-  bool skip_nested = false;
   int n;
 
   /* Don't evaluate the arguments for realloc_lhs_loop_for_fcn_call; otherwise,
@@ -2487,12 +2486,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
 	  /* Add the expressions for scalar and vector subscripts.  */
 	  for (n = 0; n < GFC_MAX_DIMENSIONS; n++)
 	    if (info->subscript[n])
-	      {
-		gfc_add_loop_ss_code (loop, info->subscript[n], true, where);
-		/* The recursive call will have taken care of the nested loops.
-		   No need to do it twice.  */
-		skip_nested = true;
-	      }
+	      gfc_add_loop_ss_code (loop, info->subscript[n], true, where);
 
 	  set_vector_loop_bounds (ss);
 	  break;
@@ -2548,7 +2542,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
 	}
     }
 
-  if (!skip_nested)
+  if (!subscript)
     for (nested_loop = loop->nested; nested_loop;
 	 nested_loop = nested_loop->next)
       gfc_add_loop_ss_code (nested_loop, nested_loop->ss, subscript, where);

Attachment: pr53732_1-test.CL
Description: Text document

Attachment: inline_sum_4.f90
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]