This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: regressions with recent subref_array_pointer changes


Steve,

Thanks for the quick exchange off-list. It enabled me to find the bug.

It would help a lot if you could identify which of the assignments is causing the trouble by eliminating blocks until it goes away. Which system is this by the way and does the problem occur at all levels of optimization?


The problem was all down to the gfc_cleanup_loop (&loop) at the end of gfc_conv_expr_descriptor. This was wiping out the ss that was being used for the rhs descriptor and, hence, its element size. There is no recourse but to use gfc_conv_expr to regenerate the descriptor. The attached patch does the job. The check for constant-ness after the fold_convert is to avoid littering up the place with extraneous code.

Bootstrapped and regtested on x86_ia64/FC5.

I will commit just as soon as you confirm that the fix works for you.

Cheers

Paul
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c	(revision 128613)
--- gcc/fortran/trans-expr.c	(working copy)
*************** gfc_trans_pointer_assignment (gfc_expr *
*** 3499,3512 ****
  	  gfc_conv_expr_descriptor (&lse, expr2, rss);
  
  	  /* If this is a subreference array pointer assignment, use the rhs
! 	     element size for the lhs span.  */
  	  if (expr1->symtree->n.sym->attr.subref_array_pointer)
  	    {
  	      decl = expr1->symtree->n.sym->backend_decl;
! 	      tmp = rss->data.info.descriptor;
! 	      tmp = gfc_get_element_type (TREE_TYPE (tmp));
! 	      tmp = size_in_bytes (tmp);
! 	      tmp = fold_convert (gfc_array_index_type, tmp);
  	      gfc_add_modify_expr (&lse.post, GFC_DECL_SPAN(decl), tmp);
  	    }
  
--- 3499,3515 ----
  	  gfc_conv_expr_descriptor (&lse, expr2, rss);
  
  	  /* If this is a subreference array pointer assignment, use the rhs
! 	     descriptor element size for the lhs span.  */
  	  if (expr1->symtree->n.sym->attr.subref_array_pointer)
  	    {
  	      decl = expr1->symtree->n.sym->backend_decl;
! 	      gfc_init_se (&rse, NULL);
! 	      rse.descriptor_only = 1;
! 	      gfc_conv_expr (&rse, expr2);
! 	      tmp = gfc_get_element_type (TREE_TYPE (rse.expr));
! 	      tmp = fold_convert (gfc_array_index_type, size_in_bytes (tmp));
! 	      if (!INTEGER_CST_P (tmp))
! 	        gfc_add_block_to_block (&lse.post, &rse.pre);
  	      gfc_add_modify_expr (&lse.post, GFC_DECL_SPAN(decl), tmp);
  	    }
  

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