gfortran speed benchmarks

Jack Howarth howarth@bromo.msbb.uc.edu
Fri Nov 4 02:37:00 GMT 2005


Feng,
   Well that patch doesn't seem to work with gcc cvs from yesterday on
MacOS X. I find that the test_fpu.f90 source causes the resulting gfortran
compiler to crash...

gfortran  -o test_fpu_gfortran_opt -c test_fpu.f90
test_fpu.f90: In function 'crout':
test_fpu.f90:151: internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:1490
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

This using the following patch (which was obtained by applying the
patch from http://gcc.gnu.org/ml/fortran/2005-10/msg00641.html to
yesterdays cvs.
                   Jack
-------------------------------------------------------------------------------
diff -uNr gcc-4.1-20051102/gcc/fortran/gfortran.h gcc-4.1-20051102.optimize/gcc/
fortran/gfortran.h
--- gcc-4.1-20051102/gcc/fortran/gfortran.h     2005-11-02 19:43:33.000000000 -0
500
+++ gcc-4.1-20051102.optimize/gcc/fortran/gfortran.h    2005-11-03 20:15:41.0000
00000 -0500
@@ -1901,6 +1901,7 @@
 symbol_attribute gfc_expr_attr (gfc_expr *);
 
 /* trans.c */
+void* get_do_loop_block (void);
 void gfc_generate_code (gfc_namespace *);
 void gfc_generate_module_code (gfc_namespace *);
 
diff -uNr gcc-4.1-20051102/gcc/fortran/trans-array.c gcc-4.1-20051102.optimize/g
cc/fortran/trans-array.c
--- gcc-4.1-20051102/gcc/fortran/trans-array.c  2005-11-02 19:43:33.000000000 -0
500
+++ gcc-4.1-20051102.optimize/gcc/fortran/trans-array.c 2005-11-03 20:15:41.0000
00000 -0500
@@ -3670,6 +3670,7 @@
   tree tmp;
   tree desc;
   stmtblock_t block;
+  stmtblock_t *do_loop_block;
   tree start;
   tree offset;
   int full;
@@ -3930,9 +3931,14 @@
          parmtype = gfc_get_element_type (TREE_TYPE (desc));
          parmtype = gfc_get_array_type_bounds (parmtype, loop.dimen,
                                                loop.from, loop.to, 0);
-         parm = gfc_create_var (parmtype, "parm");
+         /*parm = gfc_create_var (parmtype, "parm");*/
+      parm = gfc_create_var_np (parmtype, "parm");
+      gfc_add_decl_to_function (parm);
        }
 
+      do_loop_block = (stmtblock_t *)get_do_loop_block ();
+      do_loop_block = do_loop_block == NULL ? &loop.pre : do_loop_block;
+
       offset = gfc_index_zero_node;
       dim = 0;
 
@@ -3947,7 +3953,7 @@
 
       /* Set the dtype.  */
       tmp = gfc_conv_descriptor_dtype (parm);
-      gfc_add_modify_expr (&loop.pre, tmp, gfc_get_dtype (parmtype));
+      gfc_add_modify_expr (do_loop_block, tmp, gfc_get_dtype (parmtype));
 
       if (se->direct_byref)
        base = gfc_index_zero_node;
@@ -3972,7 +3978,7 @@
 
              /* Evaluate and remember the start of the section.  */
              start = info->start[dim];
-             stride = gfc_evaluate_now (stride, &loop.pre);
+             stride = gfc_evaluate_now (stride, do_loop_block);
            }
 
          tmp = gfc_conv_array_lbound (desc, n);
@@ -4006,11 +4012,11 @@
              from = gfc_index_one_node;
            }
          tmp = gfc_conv_descriptor_lbound (parm, gfc_rank_cst[dim]);
-         gfc_add_modify_expr (&loop.pre, tmp, from);
+         gfc_add_modify_expr (do_loop_block, tmp, from);
 
          /* Set the new upper bound.  */
          tmp = gfc_conv_descriptor_ubound (parm, gfc_rank_cst[dim]);
-         gfc_add_modify_expr (&loop.pre, tmp, to);
+         gfc_add_modify_expr (do_loop_block, tmp, to);
 
          /* Multiply the stride by the section stride to get the
             total stride.  */
@@ -4023,7 +4029,7 @@
 
          /* Store the new stride.  */
          tmp = gfc_conv_descriptor_stride (parm, gfc_rank_cst[dim]);
-         gfc_add_modify_expr (&loop.pre, tmp, stride);
+         gfc_add_modify_expr (do_loop_block, tmp, stride);
 
          dim++;
        }
@@ -4033,20 +4039,20 @@
       tmp = gfc_build_indirect_ref (tmp);
       tmp = gfc_build_array_ref (tmp, offset);
       offset = gfc_build_addr_expr (gfc_array_dataptr_type (desc), tmp);
-      gfc_conv_descriptor_data_set (&loop.pre, parm, offset);
+      gfc_conv_descriptor_data_set (do_loop_block, parm, offset);
 
       if (se->direct_byref)
        {
          /* Set the offset.  */
          tmp = gfc_conv_descriptor_offset (parm);
-         gfc_add_modify_expr (&loop.pre, tmp, base);
+         gfc_add_modify_expr (do_loop_block, tmp, base);
        }
       else
        {
          /* Only the callee knows what the correct offset it, so just set
             it to zero here.  */
          tmp = gfc_conv_descriptor_offset (parm);
-         gfc_add_modify_expr (&loop.pre, tmp, gfc_index_zero_node);
+         gfc_add_modify_expr (do_loop_block, tmp, gfc_index_zero_node);
        }
       desc = parm;
     }
diff -uNr gcc-4.1-20051102/gcc/fortran/trans.c gcc-4.1-20051102.optimize/gcc/for
tran/trans.c
--- gcc-4.1-20051102/gcc/fortran/trans.c        2005-11-02 19:43:33.000000000 -0
500
+++ gcc-4.1-20051102.optimize/gcc/fortran/trans.c       2005-11-03 20:15:41.0000
00000 -0500
@@ -459,6 +459,13 @@
 #endif
 }
 
+static stmtblock_t * do_loop_block;
+
+void *
+get_do_loop_block (void)
+{
+  return (void*)do_loop_block;
+}
 
 /* Translate an executable statement.  */
 
@@ -546,7 +553,9 @@
          break;
 
        case EXEC_DO:
+    do_loop_block = █
          res = gfc_trans_do (code);
+    do_loop_block = NULL;
          break;
 
        case EXEC_DO_WHILE:
--------------------------------------------------------------------------------



More information about the Fortran mailing list