This patch changes some ubounds to extent. The patch is relative to my
type patch - but it also applies without. It also fixes a bunch fo
testsuite failures.
Build and regtested on x86-64-gnu-linux.
I intent to commit the patch soon. Comments and suggestions are welcome.
Tobias
2013-04-29 Tobias Burnus <bur...@net-b.de>
* trans-array.c (gfc_trans_dummy_array_bias, get_std_lbound,
gfc_alloc_allocatable_for_assignment): Change ubound to extent.
* trans-expr.c (gfc_trans_alloc_subarray_assign): Ditto.
* trans-intrinsic.c (gfc_conv_intrinsic_bound): Ditto.
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 49eaaae..34421df 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -8110,7 +8110,7 @@ static tree
get_std_lbound (gfc_expr *expr, tree desc, int dim, bool assumed_size)
{
tree lbound;
- tree ubound;
+ tree extent;
tree stride;
tree cond, cond1, cond3, cond4;
tree tmp;
@@ -8120,10 +8120,10 @@ get_std_lbound (gfc_expr *expr, tree desc, int dim, bool assumed_size)
{
tmp = gfc_rank_cst[dim];
lbound = gfc_conv_descriptor_lbound_get (desc, tmp);
- ubound = gfc_conv_descriptor_ubound_get (desc, tmp);
+ extent = gfc_conv_descriptor_extent_get (desc, tmp);
stride = gfc_conv_descriptor_stride_get (desc, tmp);
- cond1 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
- ubound, lbound);
+ cond1 = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
+ extent, gfc_index_zero_node);
cond3 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
stride, gfc_index_zero_node);
cond3 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
@@ -8240,7 +8240,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
tree tmp;
tree tmp2;
tree lbound;
- tree ubound;
+ tree extent;
tree desc;
tree old_desc;
tree desc2;
@@ -8248,7 +8248,6 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
tree jump_label1;
tree jump_label2;
tree neq_size;
- tree lbd;
int n;
int dim;
gfc_array_spec * as;
@@ -8411,37 +8410,24 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
for (n = 0; n < expr2->rank; n++)
{
+ lbound = gfc_index_one_node;
tmp = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type,
loop->to[n], loop->from[n]);
- tmp = fold_build2_loc (input_location, PLUS_EXPR,
+ extent = fold_build2_loc (input_location, PLUS_EXPR,
gfc_array_index_type,
tmp, gfc_index_one_node);
- lbound = gfc_index_one_node;
- ubound = tmp;
-
if (as)
- {
- lbd = get_std_lbound (expr2, desc2, n,
- as->type == AS_ASSUMED_SIZE);
- ubound = fold_build2_loc (input_location,
- MINUS_EXPR,
- gfc_array_index_type,
- ubound, lbound);
- ubound = fold_build2_loc (input_location,
- PLUS_EXPR,
- gfc_array_index_type,
- ubound, lbd);
- lbound = lbd;
- }
+ lbound = get_std_lbound (expr2, desc2, n,
+ as->type == AS_ASSUMED_SIZE);
gfc_conv_descriptor_lbound_set (&fblock, desc,
gfc_rank_cst[n],
lbound);
- gfc_conv_descriptor_ubound_set (&fblock, desc,
+ gfc_conv_descriptor_extent_set (&fblock, desc,
gfc_rank_cst[n],
- ubound);
+ extent);
gfc_conv_descriptor_stride_set (&fblock, desc,
gfc_rank_cst[n],
size1);
@@ -8455,7 +8441,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
offset, tmp2);
size1 = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type,
- tmp, size1);
+ extent, size1);
}
/* Set the lhs descriptor and scalarizer offsets. For rank > 1,
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index e21c3d2..2370f44 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5830,7 +5830,6 @@ gfc_trans_alloc_subarray_assign (tree dest, gfc_component * cm,
for (n = 0; n < expr->rank; n++)
{
- tree span;
tree lbound;
/* Obtain the correct lbound - ISO/IEC TR 15581:2001 page 9.
@@ -5860,14 +5859,7 @@ gfc_trans_alloc_subarray_assign (tree dest, gfc_component * cm,
lbound = fold_convert (gfc_array_index_type, lbound);
- /* Shift the bounds and set the offset accordingly. */
- tmp = gfc_conv_descriptor_ubound_get (dest, gfc_rank_cst[n]);
- span = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
- tmp, gfc_conv_descriptor_lbound_get (dest, gfc_rank_cst[n]));
- tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
- span, lbound);
- gfc_conv_descriptor_ubound_set (&block, dest,
- gfc_rank_cst[n], tmp);
+ /* Shift the lower_bound and set the offset accordingly. */
gfc_conv_descriptor_lbound_set (&block, dest,
gfc_rank_cst[n], lbound);
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index de3ba4a..af88a38 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -1293,9 +1293,9 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper)
tree type;
tree bound;
tree tmp;
- tree cond, cond1, cond3, cond4, size;
- tree ubound;
+ tree cond, cond1, cond3, cond4;
tree lbound;
+ tree extent;
gfc_se argse;
gfc_array_spec * as;
bool assumed_rank_lb_one;
@@ -1385,8 +1385,8 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper)
&& !CLASS_DATA (arg->expr)->attr.allocatable
&& !CLASS_DATA (arg->expr)->attr.class_pointer));
- ubound = gfc_conv_descriptor_ubound_get (desc, bound);
lbound = gfc_conv_descriptor_lbound_get (desc, bound);
+ extent = gfc_conv_descriptor_extent_get (desc, bound);
/* 13.14.53: Result value for LBOUND
@@ -1415,8 +1415,8 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper)
{
tree stride = gfc_conv_descriptor_stride_get (desc, bound);
- cond1 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
- ubound, lbound);
+ cond1 = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
+ extent, gfc_index_zero_node);
cond3 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
stride, gfc_index_zero_node);
cond3 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
@@ -1438,14 +1438,14 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper)
boolean_type_node, cond, cond5);
if (assumed_rank_lb_one)
+ tmp = extent;
+ else
{
- tmp = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, ubound, lbound);
tmp = fold_build2_loc (input_location, PLUS_EXPR,
+ gfc_array_index_type, extent, lbound);
+ tmp = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type, tmp, gfc_index_one_node);
}
- else
- tmp = ubound;
se->expr = fold_build3_loc (input_location, COND_EXPR,
gfc_array_index_type, cond,
@@ -1473,16 +1473,9 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper)
else
{
if (upper)
- {
- size = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, ubound, lbound);
- se->expr = fold_build2_loc (input_location, PLUS_EXPR,
- gfc_array_index_type, size,
- gfc_index_one_node);
- se->expr = fold_build2_loc (input_location, MAX_EXPR,
- gfc_array_index_type, se->expr,
- gfc_index_zero_node);
- }
+ se->expr = fold_build2_loc (input_location, MAX_EXPR,
+ gfc_array_index_type, extent,
+ gfc_index_zero_node);
else
se->expr = gfc_index_one_node;
}