OSDN Git Service

* trans-array.c (gfc_trans_create_temp_array): Move invariant condition
authormikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Nov 2011 22:45:41 +0000 (22:45 +0000)
committermikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Nov 2011 22:45:41 +0000 (22:45 +0000)
out of the containing loop.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180882 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c

index af37e21..9b07f76 100644 (file)
@@ -1,5 +1,10 @@
 2011-11-03  Mikael Morin  <mikael@gcc.gnu.org>
 
+       * trans-array.c (gfc_trans_create_temp_array): Move invariant condition
+       out of the containing loop. 
+
+2011-11-03  Mikael Morin  <mikael@gcc.gnu.org>
+
        * trans-array.c (gfc_conv_loop_setup, gfc_trans_create_temp_array):
        Move specloop arrays clearing from the former to the latter.
 
index 545f2fb..663d12e 100644 (file)
@@ -961,12 +961,12 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
        break;
       }
 
-  for (n = 0; n < loop->dimen; n++)
+  if (size == NULL_TREE)
     {
-      dim = ss->dim[n];
-
-      if (size == NULL_TREE)
+      for (n = 0; n < loop->dimen; n++)
        {
+         dim = ss->dim[n];
+
          /* For a callee allocated array express the loop bounds in terms
             of the descriptor fields.  */
          tmp = fold_build2_loc (input_location,
@@ -974,39 +974,42 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
                gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]),
                gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim]));
          loop->to[n] = tmp;
-         continue;
        }
-       
-      /* Store the stride and bound components in the descriptor.  */
-      gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size);
+    }
+  else
+    {
+      for (n = 0; n < loop->dimen; n++)
+       {
+         /* Store the stride and bound components in the descriptor.  */
+         gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size);
 
-      gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n],
-                                     gfc_index_zero_node);
+         gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n],
+                                         gfc_index_zero_node);
 
-      gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n],
-                                     to[n]);
+         gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n], to[n]);
 
-      tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-                            to[n], gfc_index_one_node);
+         tmp = fold_build2_loc (input_location, PLUS_EXPR,
+                                gfc_array_index_type,
+                                to[n], gfc_index_one_node);
 
-      /* Check whether the size for this dimension is negative.  */
-      cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, tmp,
-                             gfc_index_zero_node);
-      cond = gfc_evaluate_now (cond, pre);
+         /* Check whether the size for this dimension is negative.  */
+         cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
+                                 tmp, gfc_index_zero_node);
+         cond = gfc_evaluate_now (cond, pre);
 
-      if (n == 0)
-       or_expr = cond;
-      else
-       or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR,
-                                  boolean_type_node, or_expr, cond);
+         if (n == 0)
+           or_expr = cond;
+         else
+           or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+                                      boolean_type_node, or_expr, cond);
 
-      size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
-                             size, tmp);
-      size = gfc_evaluate_now (size, pre);
+         size = fold_build2_loc (input_location, MULT_EXPR,
+                                 gfc_array_index_type, size, tmp);
+         size = gfc_evaluate_now (size, pre);
+       }
     }
 
   /* Get the size of the array.  */
-
   if (size && !callee_alloc)
     {
       /* If or_expr is true, then the extent in at least one