The following patch compares the stride multiplier rather than the
stride; that's not only faster as it avoids an useless division, but it
also fixes gfortran.dg/associated_2.f90 by not dividing by zero.
Build and regtested on x86-64-gnu-linux, and committed as Rev. 189492.
Remaining 12 (branch-only) regressions (without pending patches):
gfortran.dg/auto_char_dummy_array_1.f90
gfortran.dg/auto_char_len_3.f90
gfortran.dg/class_array_1.f03
gfortran.dg/class_array_2.f03
gfortran.dg/class_array_3.f03
gfortran.dg/class_to_type_1.f03
gfortran.dg/proc_decl_23.f90
gfortran.dg/select_type_26.f03
gfortran.dg/select_type_27.f03
gfortran.dg/read_eof_all.f90
gfortran.dg/transfer_intrinsic_3.f90
gfortran.dg/subref_array_pointer_2.f90
I think when we are down to zero (branch-only) regressions, we should
try a bunch of real-world programs – there are probably more issues.
Tobias
2012-07-15 Tobias Burnus <bur...@net-b.de>
* trans-intrinsic.c (gfc_conv_associated): Compare sm
instead of stride.
2012-07-15 Tobias Burnus <bur...@net-b.de>
* intrinsics/associated.c (associated): Compare sm
instead of stride.
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (Revision 189481)
+++ gcc/fortran/trans-intrinsic.c (Arbeitskopie)
@@ -5849,19 +5849,19 @@ gfc_conv_associated (gfc_se *se, gfc_exp
se->expr = fold_build2_loc (input_location, TRUTH_AND_EXPR,
boolean_type_node, tmp, tmp2);
}
else
{
/* An array pointer of zero length is not associated if target is
present. */
arg1se.descriptor_only = 1;
gfc_conv_expr_lhs (&arg1se, arg1->expr);
- tmp = gfc_conv_descriptor_stride_get (arg1se.expr,
+ tmp = gfc_conv_descriptor_sm_get (arg1se.expr,
gfc_rank_cst[arg1->expr->rank - 1]);
nonzero_arraylen = fold_build2_loc (input_location, NE_EXPR,
boolean_type_node, tmp,
build_int_cst (TREE_TYPE (tmp), 0));
/* A pointer to an array, call library function _gfor_associated. */
gcc_assert (ss2 != gfc_ss_terminator);
arg1se.want_pointer = 1;
gfc_conv_expr_descriptor (&arg1se, arg1->expr, ss1);
Index: libgfortran/intrinsics/associated.c
===================================================================
--- libgfortran/intrinsics/associated.c (Revision 189480)
+++ libgfortran/intrinsics/associated.c (Arbeitskopie)
@@ -42,17 +42,17 @@ associated (const gfc_array_void *pointe
rank = GFC_DESCRIPTOR_RANK (pointer);
for (n = 0; n < rank; n++)
{
long extent;
extent = GFC_DESCRIPTOR_EXTENT(pointer,n);
if (extent != GFC_DESCRIPTOR_EXTENT(target,n))
return 0;
- if (GFC_DESCRIPTOR_STRIDE(pointer,n) != GFC_DESCRIPTOR_STRIDE(target,n) && extent != 1)
+ if (GFC_DESCRIPTOR_SM (pointer,n) != GFC_DESCRIPTOR_SM (target,n) && extent != 1)
return 0;
if (extent <= 0)
return 0;
}
return 1;
}