------- Comment #6 from pault at gcc dot gnu dot org  2008-04-19 08:45 -------
This fixes it, albeit with one regression (scalarize_parameter_array_1.f90):

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c   (revision 134362)
--- gcc/fortran/trans-array.c   (working copy)
*************** gfc_trans_array_constructor (gfc_loopinf
*** 1679,1684 ****
--- 1679,1685 ----
    tree offsetvar;
    tree desc;
    tree type;
+   tree loopfrom;
    bool dynamic;

    if (flag_bounds_check && ss->expr->ts.type == BT_CHARACTER)
*************** gfc_trans_array_constructor (gfc_loopinf
*** 1757,1765 ****
--- 1758,1783 ----
        }
      }

+   if (!integer_zerop (loop->from[0]))
+     {
+       loopfrom = loop->from[0];
+       loop->from[0] = gfc_index_zero_node;
+       loop->to[0] = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+                                loop->to[0], loopfrom);
+     }
+   else
+     loopfrom = NULL_TREE;
+ 
    gfc_trans_create_temp_array (&loop->pre, &loop->post, loop, &ss->data.info,
                               type, dynamic, true, false);

+   if (loopfrom != NULL_TREE)
+     {
+       loop->from[0] = loopfrom;
+       loop->to[0] = fold_build2 (PLUS_EXPR, gfc_array_index_type,
+                                loop->to[0], loopfrom);
+     }
+ 
    desc = ss->data.info.descriptor;
    offset = gfc_index_zero_node;
    offsetvar = gfc_create_var_np (gfc_array_index_type, "offset");
*************** gfc_trans_array_constructor (gfc_loopinf
*** 1768,1773 ****
--- 1786,1794 ----
    gfc_trans_array_constructor_value (&loop->pre, type, desc, c,
                                     &offset, &offsetvar, dynamic);

+   ss->data.info.offset = fold_build1 (NEGATE_EXPR, gfc_array_index_type,
+                                     loop->from[0]);
+ 
    /* If the array grows dynamically, the upper bound of the loop variable
       is determined by the array's final upper bound.  */
    if (dynamic)

Somewhere along the line, the scalarizer has undergone a change in the way in
which the loop ranges are chosen.  In 4.2 and earlier, the loop->from[0] is
zero and this gives a temporary with the right offset and lbound.

I'll figure out why the regression occurs and see if there is a cleaner way of
effecting the same modification.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-04-16 18:36:40         |2008-04-19 08:45:44
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35946

Reply via email to