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]

Re: [gfortran] Fix bug for size of array allocation


canqun@nudt.edu.cn wrote:

The size for array allocation is wrong. gfc_array_init_size (trans-array.c) already calculate the total size for the allocation array, but gfc_array_allocate duplicately multiply the array element size. This is one of the reason why gfortran failed to pass 191.fma3d of SPEC CFP2000.

As far as I can see, this is OK.


I committed your patch, attached below.

Thanks,


-- Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290 Saturnushof 14, 3738 XG Maartensdijk, The Netherlands Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html GNU Fortran 95: http://gcc.gnu.org/fortran/ (under construction)
2004-01-10  Canqun Yang <canqun@nudt.edu.cn>

	* trans-array (gfc_conv_loop_setup): Adjust comment to track
	reality.
	(gfc_array_allocate): Don't count size of element twice.

*** trans-array.c.orig	Fri Dec  5 22:41:49 2003
--- trans-array.c	Sat Jan 10 13:34:03 2004
*************** gfc_conv_loop_setup (gfc_loopinfo * loop
*** 2407,2413 ****
  
  /* Fills in an array descriptor, and returns the size of the array.  The size
     will be a simple_val, ie a variable or a constant.  Also calculates the
!    offset of the base.  Returns the number of elements in the arrary.
     {
      stride = 1;
      offset = 0;
--- 2407,2413 ----
  
  /* Fills in an array descriptor, and returns the size of the array.  The size
     will be a simple_val, ie a variable or a constant.  Also calculates the
!    offset of the base.  Returns the size of the arrary.
     {
      stride = 1;
      offset = 0;
*************** gfc_array_allocate (gfc_se * se, gfc_ref
*** 2582,2592 ****
    size = gfc_array_init_size (se->expr, ref->u.ar.as->rank, &offset,
  			      lower, upper, &se->pre, &len);
  
-   /* The size is the number of elements in the array, so multiply by the
-      size of an element to get the total size.  */
-   tmp = TYPE_SIZE_UNIT (gfc_get_element_type (TREE_TYPE (se->expr)));
-   size = fold (build (MULT_EXPR, gfc_array_index_type, size, tmp));
- 
    /* Allocate memory to store the data.  */
    tmp = gfc_conv_descriptor_data (se->expr);
    pointer = gfc_build_addr_expr (NULL, tmp);
--- 2582,2587 ----

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