[Bug fortran/40598] Some missed optimizations in array assignment

pault at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Jun 30 12:57:00 GMT 2009



------- Comment #4 from pault at gcc dot gnu dot org  2009-06-30 12:57 -------
Modifying trans-expr (gfc_trans_zero_assign) to:

  tmp =  build4 (ARRAY_RANGE_REF, TREE_TYPE (dest), dest, 
                  build_int_cst (gfc_array_index_type, 3),
                  NULL_TREE, NULL_TREE);

  /* If we are zeroing a local array avoid taking its address by emitting
     a = {} instead.  */
  if (!POINTER_TYPE_P (TREE_TYPE (dest)))
    return build2 (MODIFY_EXPR, void_type_node,
                   tmp, build_constructor (TREE_TYPE (tmp), NULL));

produces:

  array[3 ...] = {};
  {
    struct __st_parameter_dt dt_parm.2;

    dt_parm.2.common.filename = &"test.f90"[1]{lb: 1 sz: 1};
    dt_parm.2.common.line = 4;
    dt_parm.2.common.flags = 128;
    dt_parm.2.common.unit = 6;
    _gfortran_st_write (&dt_parm.2);

for:

  integer :: array (3, 3)
  array = 1
  array = 0
  print *, array
end

and the output is:

[prt@localhost tmp]# ./a.out
           1           1           1           0           0           0       
   0           0           0
Segmentation fault

So the lower bound for the reference seems to be OK but I have not understood
how to set the upper bound.  If I set argument three, the lower bound is reset
to zero and the size of the array reference is determined by arg 3.  This also
gets rid of the seg fault.

I obviously do not have the faintest idea of what I am doing!  I notice as well
that the ARRAY_RANGE_REF is not used very much.

Paul


-- 


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



More information about the Gcc-bugs mailing list