------- Comment #1 from rguenth at gcc dot gnu dot org  2006-12-07 21:54 -------
A little playing around and looking at the allocate() implementation in
libgfortran suggests that it is possible to fix this.

Index: trans-array.c
===================================================================
--- trans-array.c       (revision 119622)
+++ trans-array.c       (working copy)
@@ -3355,31 +3355,29 @@ gfc_array_allocate (gfc_se * se, gfc_exp
                              lower, upper, &se->pre);

   /* Allocate memory to store the data.  */
-  tmp = gfc_conv_descriptor_data_addr (se->expr);
-  pointer = gfc_evaluate_now (tmp, &se->pre);
+  pointer = gfc_conv_descriptor_data_get (se->expr);
+  STRIP_NOPS (pointer);

   if (TYPE_PRECISION (gfc_array_index_type) == 32)
     {
       if (allocatable_array)
-       allocate = gfor_fndecl_allocate_array;
+       allocate = gfor_fndecl_internal_malloc;
       else
-       allocate = gfor_fndecl_allocate;
+       allocate = gfor_fndecl_internal_malloc;
     }
   else if (TYPE_PRECISION (gfc_array_index_type) == 64)
     {
       if (allocatable_array)
-       allocate = gfor_fndecl_allocate64_array;
+       allocate = gfor_fndecl_internal_malloc64;
       else
-       allocate = gfor_fndecl_allocate64;
+       allocate = gfor_fndecl_internal_malloc64;
     }
   else
     gcc_unreachable ();

-  tmp = gfc_chainon_list (NULL_TREE, pointer);
-  tmp = gfc_chainon_list (tmp, size);
-  tmp = gfc_chainon_list (tmp, pstat);
+  tmp = gfc_chainon_list (NULL_TREE, size);
   tmp = build_function_call_expr (allocate, tmp);
-  gfc_add_expr_to_block (&se->pre, tmp);
+  gfc_add_expr_to_block (&se->pre, build2 (MODIFY_EXPR, void_type_node,
pointer, tmp));

   tmp = gfc_conv_descriptor_offset (se->expr);
   gfc_add_modify_expr (&se->pre, tmp, offset);


this generates 

  D.3240_65 = _gfortran_internal_malloc64 (size.310_298);
  #   SFT.762_6097 = V_MUST_DEF <SFT.762_9320>;
  strain_tensor.data = D.3240_65;

which then produces a HEAP_VAR and enables sincos transformation in PR30038.


-- 


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

Reply via email to