* [PATCH] Do array index calculations in gfc_array_index_type
@ 2018-09-22 19:22 Janne Blomqvist
2018-09-23 9:40 ` Paul Richard Thomas
2018-09-24 13:54 ` Andreas Schwab
0 siblings, 2 replies; 7+ messages in thread
From: Janne Blomqvist @ 2018-09-22 19:22 UTC (permalink / raw)
To: fortran, gcc-patches; +Cc: Janne Blomqvist
It was recently noticed that for a few of the coarray intrinsics array
index calculations were done in integer_type_node instead of
gfc_array_index_type. This patch fixes this.
Regtested on x86_64-pc-linux-gnu, Ok for trunk?
gcc/fortran/ChangeLog:
2018-09-22 Janne Blomqvist <jb@gcc.gnu.org>
* trans-expr.c (gfc_caf_get_image_index): Do array index
calculations in gfc_array_index_type.
* trans-intrinsic.c (conv_intrinsic_event_query): Likewise.
* trans-stmt.c (gfc_trans_lock_unlock): Likewise.
(gfc_trans_event_post_wait): Likewise.
gcc/testsuite/ChangeLog:
2018-09-22 Janne Blomqvist <jb@gcc.gnu.org>
* gfortran.dg/coarray_lib_alloc_4.f90: Fix scan patterns.
* gfortran.dg/coarray_lock_7.f90: Likewise.
---
gcc/fortran/trans-expr.c | 42 +++++++++----------
gcc/fortran/trans-intrinsic.c | 18 ++++----
gcc/fortran/trans-stmt.c | 34 +++++++--------
.../gfortran.dg/coarray_lib_alloc_4.f90 | 2 +-
gcc/testsuite/gfortran.dg/coarray_lock_7.f90 | 12 +++---
5 files changed, 48 insertions(+), 60 deletions(-)
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 1f94dcf11dd..bfda2bd746a 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -2095,60 +2095,56 @@ gfc_caf_get_image_index (stmtblock_t *block, gfc_expr *e, tree desc)
integer_zero_node);
}
- img_idx = integer_zero_node;
- extent = integer_one_node;
+ img_idx = build_zero_cst (gfc_array_index_type);
+ extent = build_one_cst (gfc_array_index_type);
if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc)))
for (i = ref->u.ar.dimen; i < ref->u.ar.dimen + ref->u.ar.codimen; i++)
{
gfc_init_se (&se, NULL);
- gfc_conv_expr_type (&se, ref->u.ar.start[i], integer_type_node);
+ gfc_conv_expr_type (&se, ref->u.ar.start[i], gfc_array_index_type);
gfc_add_block_to_block (block, &se.pre);
lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
tmp = fold_build2_loc (input_location, MINUS_EXPR,
- integer_type_node, se.expr,
- fold_convert(integer_type_node, lbound));
- tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node,
+ TREE_TYPE (lbound), se.expr, lbound);
+ tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
extent, tmp);
- img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
- img_idx, tmp);
+ img_idx = fold_build2_loc (input_location, PLUS_EXPR,
+ TREE_TYPE (tmp), img_idx, tmp);
if (i < ref->u.ar.dimen + ref->u.ar.codimen - 1)
{
ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
- tmp = fold_convert (integer_type_node, tmp);
extent = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
}
}
else
for (i = ref->u.ar.dimen; i < ref->u.ar.dimen + ref->u.ar.codimen; i++)
{
gfc_init_se (&se, NULL);
- gfc_conv_expr_type (&se, ref->u.ar.start[i], integer_type_node);
+ gfc_conv_expr_type (&se, ref->u.ar.start[i], gfc_array_index_type);
gfc_add_block_to_block (block, &se.pre);
lbound = GFC_TYPE_ARRAY_LBOUND (TREE_TYPE (desc), i);
- lbound = fold_convert (integer_type_node, lbound);
tmp = fold_build2_loc (input_location, MINUS_EXPR,
- integer_type_node, se.expr, lbound);
- tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node,
+ TREE_TYPE (lbound), se.expr, lbound);
+ tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
extent, tmp);
- img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
+ img_idx = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (tmp),
img_idx, tmp);
if (i < ref->u.ar.dimen + ref->u.ar.codimen - 1)
{
ubound = GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (desc), i);
- ubound = fold_convert (integer_type_node, ubound);
tmp = fold_build2_loc (input_location, MINUS_EXPR,
- integer_type_node, ubound, lbound);
- tmp = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
- tmp, integer_one_node);
+ TREE_TYPE (ubound), ubound, lbound);
+ tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (tmp),
+ tmp, build_one_cst (TREE_TYPE (tmp)));
extent = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
}
}
- img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
- img_idx, integer_one_node);
- return img_idx;
+ img_idx = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (img_idx),
+ img_idx, build_one_cst (TREE_TYPE (img_idx)));
+ return fold_convert (integer_type_node, img_idx);
}
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 11fd4b94fcc..639175ade71 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -10663,7 +10663,7 @@ conv_intrinsic_event_query (gfc_code *code)
if (flag_coarray == GFC_FCOARRAY_LIB)
{
tree tmp, token, image_index;
- tree index = size_zero_node;
+ tree index = build_zero_cst (gfc_array_index_type);
if (event_expr->expr_type == EXPR_FUNCTION
&& event_expr->value.function.isym
@@ -10716,29 +10716,25 @@ conv_intrinsic_event_query (gfc_code *code)
desc = argse.expr;
*ar = ar2;
- extent = integer_one_node;
+ extent = build_one_cst (gfc_array_index_type);
for (i = 0; i < ar->dimen; i++)
{
gfc_init_se (&argse, NULL);
- gfc_conv_expr_type (&argse, ar->start[i], integer_type_node);
+ gfc_conv_expr_type (&argse, ar->start[i], gfc_array_index_type);
gfc_add_block_to_block (&argse.pre, &argse.pre);
lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
tmp = fold_build2_loc (input_location, MINUS_EXPR,
- integer_type_node, argse.expr,
- fold_convert(integer_type_node, lbound));
+ TREE_TYPE (lbound), argse.expr, lbound);
tmp = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
index = fold_build2_loc (input_location, PLUS_EXPR,
- gfc_array_index_type, index,
- fold_convert (gfc_array_index_type,
- tmp));
+ TREE_TYPE (tmp), index, tmp);
if (i < ar->dimen - 1)
{
ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
- tmp = fold_convert (integer_type_node, tmp);
extent = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
}
}
}
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 833c6c5f0a7..ef9e519adc8 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -841,7 +841,7 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
if (flag_coarray == GFC_FCOARRAY_LIB)
{
tree tmp, token, image_index, errmsg, errmsg_len;
- tree index = size_zero_node;
+ tree index = build_zero_cst (gfc_array_index_type);
tree caf_decl = gfc_get_tree_for_caf_expr (code->expr1);
if (code->expr1->symtree->n.sym->ts.type != BT_DERIVED
@@ -884,27 +884,25 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
desc = argse.expr;
*ar = ar2;
- extent = integer_one_node;
+ extent = build_one_cst (gfc_array_index_type);
for (i = 0; i < ar->dimen; i++)
{
gfc_init_se (&argse, NULL);
- gfc_conv_expr_type (&argse, ar->start[i], integer_type_node);
+ gfc_conv_expr_type (&argse, ar->start[i], gfc_array_index_type);
gfc_add_block_to_block (&argse.pre, &argse.pre);
lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
tmp = fold_build2_loc (input_location, MINUS_EXPR,
- integer_type_node, argse.expr,
- fold_convert(integer_type_node, lbound));
+ TREE_TYPE (lbound), argse.expr, lbound);
tmp = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
index = fold_build2_loc (input_location, PLUS_EXPR,
- integer_type_node, index, tmp);
+ TREE_TYPE (tmp), index, tmp);
if (i < ar->dimen - 1)
{
ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
- tmp = fold_convert (integer_type_node, tmp);
extent = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
}
}
}
@@ -938,6 +936,7 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
lock_acquired = gfc_create_var (integer_type_node, "acquired");
}
+ index = fold_convert (size_type_node, index);
if (op == EXEC_LOCK)
tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_lock, 7,
token, index, image_index,
@@ -1038,7 +1037,7 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
gfc_start_block (&se.pre);
tree tmp, token, image_index, errmsg, errmsg_len;
- tree index = size_zero_node;
+ tree index = build_zero_cst (gfc_array_index_type);
tree caf_decl = gfc_get_tree_for_caf_expr (code->expr1);
if (code->expr1->symtree->n.sym->ts.type != BT_DERIVED
@@ -1083,28 +1082,25 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
desc = argse.expr;
*ar = ar2;
- extent = integer_one_node;
+ extent = build_one_cst (gfc_array_index_type);
for (i = 0; i < ar->dimen; i++)
{
gfc_init_se (&argse, NULL);
- gfc_conv_expr_type (&argse, ar->start[i], integer_type_node);
+ gfc_conv_expr_type (&argse, ar->start[i], gfc_array_index_type);
gfc_add_block_to_block (&argse.pre, &argse.pre);
lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
tmp = fold_build2_loc (input_location, MINUS_EXPR,
- integer_type_node, argse.expr,
- fold_convert(integer_type_node, lbound));
+ TREE_TYPE (lbound), argse.expr, lbound);
tmp = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
index = fold_build2_loc (input_location, PLUS_EXPR,
- gfc_array_index_type, index,
- fold_convert (gfc_array_index_type, tmp));
+ TREE_TYPE (tmp), index, tmp);
if (i < ar->dimen - 1)
{
ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
- tmp = fold_convert (integer_type_node, tmp);
extent = fold_build2_loc (input_location, MULT_EXPR,
- integer_type_node, extent, tmp);
+ TREE_TYPE (tmp), extent, tmp);
}
}
}
diff --git a/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90 b/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90
index c08378816ca..d695faa9eaf 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90
@@ -38,7 +38,7 @@ program test_caf_alloc
deallocate(xx)
end
-! { dg-final { scan-tree-dump-times "_gfortran_caf_is_present \\(xx\\.token, 2 - \\(integer\\(kind=4\\)\\) xx\\.dim\\\[0\\\]\\.lbound, &caf_ref\\.\[0-9\]+\\)|_gfortran_caf_is_present \\(xx\\.token, 2 - xx\\.dim\\\[0\\\]\\.lbound, &caf_ref\\.\[0-9\]+\\)" 10 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_is_present \\(xx\\.token, \\(integer\\(kind=4\\)\\) \\(2 - xx\\.dim\\\[0\\\]\\.lbound\\), &caf_ref\\.\[0-9\]+\\)|_gfortran_caf_is_present \\(xx\\.token, 2 - xx\\.dim\\\[0\\\]\\.lbound, &caf_ref\\.\[0-9\]+\\)" 10 "original" } }
! { dg-final { scan-tree-dump-times "_gfortran_caf_register \\(\[0-9\]+, 1, &xx\\.token, \\(void \\*\\) &xx, 0B, 0B, 0\\)" 1 "original" } }
! { dg-final { scan-tree-dump-times "_gfortran_caf_register \\(\[0-9\]+, 7" 2 "original" } }
! { dg-final { scan-tree-dump-times "_gfortran_caf_register \\(\[0-9\]+, 8" 2 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90 b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
index 1478c7a9539..363fb30b5d7 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
@@ -35,12 +35,12 @@ end
! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., 0, 0, 0B, 0B, 0B, 0\\);" 1 "original" } }
! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., 0, 0, 0B, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., \\(3 - \\(integer\\(kind=4\\)\\) parm...dim\\\[0\\\].lbound\\) \\+ \\(integer\\(kind=4\\)\\) \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - \\(integer\\(kind=4\\)\\) parm...dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., \\(2 - \\(integer\\(kind=4\\)\\) parm...dim\\\[0\\\].lbound\\) \\+ \\(integer\\(kind=4\\)\\) \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - \\(integer\\(kind=4\\)\\) parm...dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., .*\\(\\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\)\\), 0, 0B, &ii, 0B, 0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., .*\\(\\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\)\\), 0, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, 5 - \\(integer\\(kind=4\\)\\) three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, 8 - \\(integer\\(kind=4\\)\\) three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(5 - three.dim\\\[0\\\].lbound\\), &acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(8 - three.dim\\\[0\\\].lbound\\), &ii, 0B, 0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, 1 - \\(integer\\(kind=4\\)\\) four.dim\\\[0\\\].lbound, 7 - \\(integer\\(kind=4\\)\\) four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, 2 - \\(integer\\(kind=4\\)\\) four.dim\\\[0\\\].lbound, 8 - \\(integer\\(kind=4\\)\\) four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\), &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do array index calculations in gfc_array_index_type
2018-09-22 19:22 [PATCH] Do array index calculations in gfc_array_index_type Janne Blomqvist
@ 2018-09-23 9:40 ` Paul Richard Thomas
2018-09-24 13:54 ` Andreas Schwab
1 sibling, 0 replies; 7+ messages in thread
From: Paul Richard Thomas @ 2018-09-23 9:40 UTC (permalink / raw)
To: Janne Blomqvist; +Cc: fortran, gcc-patches
Hi Janne,
Good catch - thanks for dealing with this.
OK for trunk.
Paul
On 22 September 2018 at 20:21, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> It was recently noticed that for a few of the coarray intrinsics array
> index calculations were done in integer_type_node instead of
> gfc_array_index_type. This patch fixes this.
>
> Regtested on x86_64-pc-linux-gnu, Ok for trunk?
>
> gcc/fortran/ChangeLog:
>
> 2018-09-22 Janne Blomqvist <jb@gcc.gnu.org>
>
> * trans-expr.c (gfc_caf_get_image_index): Do array index
> calculations in gfc_array_index_type.
> * trans-intrinsic.c (conv_intrinsic_event_query): Likewise.
> * trans-stmt.c (gfc_trans_lock_unlock): Likewise.
> (gfc_trans_event_post_wait): Likewise.
>
> gcc/testsuite/ChangeLog:
>
> 2018-09-22 Janne Blomqvist <jb@gcc.gnu.org>
>
> * gfortran.dg/coarray_lib_alloc_4.f90: Fix scan patterns.
> * gfortran.dg/coarray_lock_7.f90: Likewise.
> ---
> gcc/fortran/trans-expr.c | 42 +++++++++----------
> gcc/fortran/trans-intrinsic.c | 18 ++++----
> gcc/fortran/trans-stmt.c | 34 +++++++--------
> .../gfortran.dg/coarray_lib_alloc_4.f90 | 2 +-
> gcc/testsuite/gfortran.dg/coarray_lock_7.f90 | 12 +++---
> 5 files changed, 48 insertions(+), 60 deletions(-)
>
> diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
> index 1f94dcf11dd..bfda2bd746a 100644
> --- a/gcc/fortran/trans-expr.c
> +++ b/gcc/fortran/trans-expr.c
> @@ -2095,60 +2095,56 @@ gfc_caf_get_image_index (stmtblock_t *block, gfc_expr *e, tree desc)
> integer_zero_node);
> }
>
> - img_idx = integer_zero_node;
> - extent = integer_one_node;
> + img_idx = build_zero_cst (gfc_array_index_type);
> + extent = build_one_cst (gfc_array_index_type);
> if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc)))
> for (i = ref->u.ar.dimen; i < ref->u.ar.dimen + ref->u.ar.codimen; i++)
> {
> gfc_init_se (&se, NULL);
> - gfc_conv_expr_type (&se, ref->u.ar.start[i], integer_type_node);
> + gfc_conv_expr_type (&se, ref->u.ar.start[i], gfc_array_index_type);
> gfc_add_block_to_block (block, &se.pre);
> lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
> tmp = fold_build2_loc (input_location, MINUS_EXPR,
> - integer_type_node, se.expr,
> - fold_convert(integer_type_node, lbound));
> - tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node,
> + TREE_TYPE (lbound), se.expr, lbound);
> + tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
> extent, tmp);
> - img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
> - img_idx, tmp);
> + img_idx = fold_build2_loc (input_location, PLUS_EXPR,
> + TREE_TYPE (tmp), img_idx, tmp);
> if (i < ref->u.ar.dimen + ref->u.ar.codimen - 1)
> {
> ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
> tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
> - tmp = fold_convert (integer_type_node, tmp);
> extent = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> }
> }
> else
> for (i = ref->u.ar.dimen; i < ref->u.ar.dimen + ref->u.ar.codimen; i++)
> {
> gfc_init_se (&se, NULL);
> - gfc_conv_expr_type (&se, ref->u.ar.start[i], integer_type_node);
> + gfc_conv_expr_type (&se, ref->u.ar.start[i], gfc_array_index_type);
> gfc_add_block_to_block (block, &se.pre);
> lbound = GFC_TYPE_ARRAY_LBOUND (TREE_TYPE (desc), i);
> - lbound = fold_convert (integer_type_node, lbound);
> tmp = fold_build2_loc (input_location, MINUS_EXPR,
> - integer_type_node, se.expr, lbound);
> - tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node,
> + TREE_TYPE (lbound), se.expr, lbound);
> + tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
> extent, tmp);
> - img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
> + img_idx = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (tmp),
> img_idx, tmp);
> if (i < ref->u.ar.dimen + ref->u.ar.codimen - 1)
> {
> ubound = GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (desc), i);
> - ubound = fold_convert (integer_type_node, ubound);
> tmp = fold_build2_loc (input_location, MINUS_EXPR,
> - integer_type_node, ubound, lbound);
> - tmp = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
> - tmp, integer_one_node);
> + TREE_TYPE (ubound), ubound, lbound);
> + tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (tmp),
> + tmp, build_one_cst (TREE_TYPE (tmp)));
> extent = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> }
> }
> - img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node,
> - img_idx, integer_one_node);
> - return img_idx;
> + img_idx = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (img_idx),
> + img_idx, build_one_cst (TREE_TYPE (img_idx)));
> + return fold_convert (integer_type_node, img_idx);
> }
>
>
> diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
> index 11fd4b94fcc..639175ade71 100644
> --- a/gcc/fortran/trans-intrinsic.c
> +++ b/gcc/fortran/trans-intrinsic.c
> @@ -10663,7 +10663,7 @@ conv_intrinsic_event_query (gfc_code *code)
> if (flag_coarray == GFC_FCOARRAY_LIB)
> {
> tree tmp, token, image_index;
> - tree index = size_zero_node;
> + tree index = build_zero_cst (gfc_array_index_type);
>
> if (event_expr->expr_type == EXPR_FUNCTION
> && event_expr->value.function.isym
> @@ -10716,29 +10716,25 @@ conv_intrinsic_event_query (gfc_code *code)
> desc = argse.expr;
> *ar = ar2;
>
> - extent = integer_one_node;
> + extent = build_one_cst (gfc_array_index_type);
> for (i = 0; i < ar->dimen; i++)
> {
> gfc_init_se (&argse, NULL);
> - gfc_conv_expr_type (&argse, ar->start[i], integer_type_node);
> + gfc_conv_expr_type (&argse, ar->start[i], gfc_array_index_type);
> gfc_add_block_to_block (&argse.pre, &argse.pre);
> lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
> tmp = fold_build2_loc (input_location, MINUS_EXPR,
> - integer_type_node, argse.expr,
> - fold_convert(integer_type_node, lbound));
> + TREE_TYPE (lbound), argse.expr, lbound);
> tmp = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> index = fold_build2_loc (input_location, PLUS_EXPR,
> - gfc_array_index_type, index,
> - fold_convert (gfc_array_index_type,
> - tmp));
> + TREE_TYPE (tmp), index, tmp);
> if (i < ar->dimen - 1)
> {
> ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
> tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
> - tmp = fold_convert (integer_type_node, tmp);
> extent = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> }
> }
> }
> diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
> index 833c6c5f0a7..ef9e519adc8 100644
> --- a/gcc/fortran/trans-stmt.c
> +++ b/gcc/fortran/trans-stmt.c
> @@ -841,7 +841,7 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
> if (flag_coarray == GFC_FCOARRAY_LIB)
> {
> tree tmp, token, image_index, errmsg, errmsg_len;
> - tree index = size_zero_node;
> + tree index = build_zero_cst (gfc_array_index_type);
> tree caf_decl = gfc_get_tree_for_caf_expr (code->expr1);
>
> if (code->expr1->symtree->n.sym->ts.type != BT_DERIVED
> @@ -884,27 +884,25 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
> desc = argse.expr;
> *ar = ar2;
>
> - extent = integer_one_node;
> + extent = build_one_cst (gfc_array_index_type);
> for (i = 0; i < ar->dimen; i++)
> {
> gfc_init_se (&argse, NULL);
> - gfc_conv_expr_type (&argse, ar->start[i], integer_type_node);
> + gfc_conv_expr_type (&argse, ar->start[i], gfc_array_index_type);
> gfc_add_block_to_block (&argse.pre, &argse.pre);
> lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
> tmp = fold_build2_loc (input_location, MINUS_EXPR,
> - integer_type_node, argse.expr,
> - fold_convert(integer_type_node, lbound));
> + TREE_TYPE (lbound), argse.expr, lbound);
> tmp = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> index = fold_build2_loc (input_location, PLUS_EXPR,
> - integer_type_node, index, tmp);
> + TREE_TYPE (tmp), index, tmp);
> if (i < ar->dimen - 1)
> {
> ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
> tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
> - tmp = fold_convert (integer_type_node, tmp);
> extent = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> }
> }
> }
> @@ -938,6 +936,7 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
> lock_acquired = gfc_create_var (integer_type_node, "acquired");
> }
>
> + index = fold_convert (size_type_node, index);
> if (op == EXEC_LOCK)
> tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_lock, 7,
> token, index, image_index,
> @@ -1038,7 +1037,7 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
>
> gfc_start_block (&se.pre);
> tree tmp, token, image_index, errmsg, errmsg_len;
> - tree index = size_zero_node;
> + tree index = build_zero_cst (gfc_array_index_type);
> tree caf_decl = gfc_get_tree_for_caf_expr (code->expr1);
>
> if (code->expr1->symtree->n.sym->ts.type != BT_DERIVED
> @@ -1083,28 +1082,25 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
> desc = argse.expr;
> *ar = ar2;
>
> - extent = integer_one_node;
> + extent = build_one_cst (gfc_array_index_type);
> for (i = 0; i < ar->dimen; i++)
> {
> gfc_init_se (&argse, NULL);
> - gfc_conv_expr_type (&argse, ar->start[i], integer_type_node);
> + gfc_conv_expr_type (&argse, ar->start[i], gfc_array_index_type);
> gfc_add_block_to_block (&argse.pre, &argse.pre);
> lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
> tmp = fold_build2_loc (input_location, MINUS_EXPR,
> - integer_type_node, argse.expr,
> - fold_convert(integer_type_node, lbound));
> + TREE_TYPE (lbound), argse.expr, lbound);
> tmp = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> index = fold_build2_loc (input_location, PLUS_EXPR,
> - gfc_array_index_type, index,
> - fold_convert (gfc_array_index_type, tmp));
> + TREE_TYPE (tmp), index, tmp);
> if (i < ar->dimen - 1)
> {
> ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
> tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
> - tmp = fold_convert (integer_type_node, tmp);
> extent = fold_build2_loc (input_location, MULT_EXPR,
> - integer_type_node, extent, tmp);
> + TREE_TYPE (tmp), extent, tmp);
> }
> }
> }
> diff --git a/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90 b/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90
> index c08378816ca..d695faa9eaf 100644
> --- a/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90
> +++ b/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90
> @@ -38,7 +38,7 @@ program test_caf_alloc
> deallocate(xx)
> end
>
> -! { dg-final { scan-tree-dump-times "_gfortran_caf_is_present \\(xx\\.token, 2 - \\(integer\\(kind=4\\)\\) xx\\.dim\\\[0\\\]\\.lbound, &caf_ref\\.\[0-9\]+\\)|_gfortran_caf_is_present \\(xx\\.token, 2 - xx\\.dim\\\[0\\\]\\.lbound, &caf_ref\\.\[0-9\]+\\)" 10 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_is_present \\(xx\\.token, \\(integer\\(kind=4\\)\\) \\(2 - xx\\.dim\\\[0\\\]\\.lbound\\), &caf_ref\\.\[0-9\]+\\)|_gfortran_caf_is_present \\(xx\\.token, 2 - xx\\.dim\\\[0\\\]\\.lbound, &caf_ref\\.\[0-9\]+\\)" 10 "original" } }
> ! { dg-final { scan-tree-dump-times "_gfortran_caf_register \\(\[0-9\]+, 1, &xx\\.token, \\(void \\*\\) &xx, 0B, 0B, 0\\)" 1 "original" } }
> ! { dg-final { scan-tree-dump-times "_gfortran_caf_register \\(\[0-9\]+, 7" 2 "original" } }
> ! { dg-final { scan-tree-dump-times "_gfortran_caf_register \\(\[0-9\]+, 8" 2 "original" } }
> diff --git a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90 b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
> index 1478c7a9539..363fb30b5d7 100644
> --- a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
> +++ b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
> @@ -35,12 +35,12 @@ end
> ! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., 0, 0, 0B, 0B, 0B, 0\\);" 1 "original" } }
> ! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., 0, 0, 0B, 0B, 0\\);" 1 "original" } }
>
> -! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., \\(3 - \\(integer\\(kind=4\\)\\) parm...dim\\\[0\\\].lbound\\) \\+ \\(integer\\(kind=4\\)\\) \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - \\(integer\\(kind=4\\)\\) parm...dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } }
> -! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., \\(2 - \\(integer\\(kind=4\\)\\) parm...dim\\\[0\\\].lbound\\) \\+ \\(integer\\(kind=4\\)\\) \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - \\(integer\\(kind=4\\)\\) parm...dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., .*\\(\\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\)\\), 0, 0B, &ii, 0B, 0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., .*\\(\\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\)\\), 0, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm...dim\\\[0\\\].ubound - parm...dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } }
>
> -! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, 5 - \\(integer\\(kind=4\\)\\) three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } }
> -! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, 8 - \\(integer\\(kind=4\\)\\) three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);" 1 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(5 - three.dim\\\[0\\\].lbound\\), &acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(8 - three.dim\\\[0\\\].lbound\\), &ii, 0B, 0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);" 1 "original" } }
>
> -! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, 1 - \\(integer\\(kind=4\\)\\) four.dim\\\[0\\\].lbound, 7 - \\(integer\\(kind=4\\)\\) four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
> -! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, 2 - \\(integer\\(kind=4\\)\\) four.dim\\\[0\\\].lbound, 8 - \\(integer\\(kind=4\\)\\) four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\), &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
>
> --
> 2.17.1
>
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do array index calculations in gfc_array_index_type
2018-09-22 19:22 [PATCH] Do array index calculations in gfc_array_index_type Janne Blomqvist
2018-09-23 9:40 ` Paul Richard Thomas
@ 2018-09-24 13:54 ` Andreas Schwab
2018-09-24 16:49 ` Kyrill Tkachov
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2018-09-24 13:54 UTC (permalink / raw)
To: Janne Blomqvist; +Cc: fortran, gcc-patches
On Sep 22 2018, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\), &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
> +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
This is wrong for ILP32.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do array index calculations in gfc_array_index_type
2018-09-24 13:54 ` Andreas Schwab
@ 2018-09-24 16:49 ` Kyrill Tkachov
2018-09-24 19:39 ` Janne Blomqvist
0 siblings, 1 reply; 7+ messages in thread
From: Kyrill Tkachov @ 2018-09-24 16:49 UTC (permalink / raw)
To: Andreas Schwab, Janne Blomqvist; +Cc: fortran, gcc-patches
Hi all,
On 24/09/18 14:54, Andreas Schwab wrote:
> On Sep 22 2018, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
>
> > +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\), &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
> > +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
>
> This is wrong for ILP32.
>
To be more concrete, this FAILs on arm-none-linux-gnueabihf:
FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\[0\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\[1\\].lbound\\), &acquired.[0-9]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\[0\\].lbound, 7 - four.dim\\[1\\].lbound, &acquired.[0-9]+, &ii, 0B, 0\\);" 1
FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\[0\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\[1\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\[0\\].lbound, 8 - four.dim\\[1\\].lbound, 0B, 0B, 0\\);" 1
Thanks,
Kyrill
> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do array index calculations in gfc_array_index_type
2018-09-24 16:49 ` Kyrill Tkachov
@ 2018-09-24 19:39 ` Janne Blomqvist
2018-09-25 7:57 ` Jakub Jelinek
0 siblings, 1 reply; 7+ messages in thread
From: Janne Blomqvist @ 2018-09-24 19:39 UTC (permalink / raw)
To: Kyrill Tkachov; +Cc: Andreas Schwab, Fortran List, GCC Patches
On Mon, Sep 24, 2018 at 7:48 PM Kyrill Tkachov <kyrylo.tkachov@foss.arm.com>
wrote:
> Hi all,
>
> On 24/09/18 14:54, Andreas Schwab wrote:
> > On Sep 22 2018, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
> >
> > > +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock
> \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\),
> \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\),
> &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 -
> four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+,
> &ii, 0B, 0\\);" 1 "original" } }
> > > +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock
> \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\),
> \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B,
> 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 -
> four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
> >
> > This is wrong for ILP32.
> >
>
> To be more concrete, this FAILs on arm-none-linux-gnueabihf:
>
> FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original
> "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\[0\\].lbound\\),
> \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\[1\\].lbound\\),
> &acquired.[0-9]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 -
> four.dim\\[0\\].lbound, 7 - four.dim\\[1\\].lbound, &acquired.[0-9]+, &ii,
> 0B, 0\\);" 1
> FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original
> "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\[0\\].lbound\\),
> \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\[1\\].lbound\\), 0B, 0B,
> 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\[0\\].lbound, 8 -
> four.dim\\[1\\].lbound, 0B, 0B, 0\\);" 1
>
>
> Thanks,
> Kyrill
>
Ugh. My 32-bit tree is in a bit of a disarray at the moment (my lxd
container setup didn't survive the upgrade to ubuntu 18.04), can somebody
send me the .original tree dump?
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do array index calculations in gfc_array_index_type
2018-09-24 19:39 ` Janne Blomqvist
@ 2018-09-25 7:57 ` Jakub Jelinek
2018-09-25 13:13 ` Janne Blomqvist
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2018-09-25 7:57 UTC (permalink / raw)
To: Janne Blomqvist; +Cc: Kyrill Tkachov, Andreas Schwab, Fortran List, GCC Patches
On Mon, Sep 24, 2018 at 10:38:57PM +0300, Janne Blomqvist wrote:
> > On 24/09/18 14:54, Andreas Schwab wrote:
> > > On Sep 22 2018, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
> > >
> > > > +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock
> > \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\),
> > \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\),
> > &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 -
> > four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+,
> > &ii, 0B, 0\\);" 1 "original" } }
> > > > +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock
> > \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\),
> > \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B,
> > 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 -
> > four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
> > >
> > > This is wrong for ILP32.
> > >
> >
> > To be more concrete, this FAILs on arm-none-linux-gnueabihf:
> >
> > FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original
> > "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\[0\\].lbound\\),
> > \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\[1\\].lbound\\),
> > &acquired.[0-9]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 -
> > four.dim\\[0\\].lbound, 7 - four.dim\\[1\\].lbound, &acquired.[0-9]+, &ii,
> > 0B, 0\\);" 1
> > FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original
> > "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\[0\\].lbound\\),
> > \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\[1\\].lbound\\), 0B, 0B,
> > 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\[0\\].lbound, 8 -
> > four.dim\\[1\\].lbound, 0B, 0B, 0\\);" 1
>
> Ugh. My 32-bit tree is in a bit of a disarray at the moment (my lxd
> container setup didn't survive the upgrade to ubuntu 18.04), can somebody
> send me the .original tree dump?
You could just try:
make check-gfortran RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} dg.exp=coarray_lock_7.f90'
on say x86_64-linux to see how it fails.
For -m64, the last lock/unlock are:
_gfortran_caf_lock (four.token, (unsigned long) (1 - four.dim[0].lbound), (integer(kind=4)) (7 - four.dim[1].lbound), &acquired.11, &ii, 0B, 0);
_gfortran_caf_unlock (four.token, (unsigned long) (2 - four.dim[0].lbound), (integer(kind=4)) (8 - four.dim[1].lbound), 0B, 0B, 0);
while for -m32, the last lock/unlock are:
_gfortran_caf_lock (four.token, (character(kind=4)) (1 - four.dim[0].lbound), 7 - four.dim[1].lbound, &acquired.11, &ii, 0B, 0);
_gfortran_caf_unlock (four.token, (character(kind=4)) (2 - four.dim[0].lbound), 8 - four.dim[1].lbound, 0B, 0B, 0);
The regexp expects either casts on both (which is why -m64 works), or no
casts on either, but not the case when there is a cast just on the second
argument and not on the third one.
The following patch fixes it, tested with the above make check-gfortran.
Note, there are still 4 spots that use .*, that looks dangerous to me, as it
can match many lines. I'd suggest \[^\n\r]* instead.
2018-09-25 Jakub Jelinek <jakub@redhat.com>
* gfortran.dg/coarray_lock_7.f90: Adjust scan-tree-dump-times for
ILP32.
--- gcc/testsuite/gfortran.dg/coarray_lock_7.f90.jj 2018-09-24 10:36:53.367036614 +0200
+++ gcc/testsuite/gfortran.dg/coarray_lock_7.f90 2018-09-25 09:48:33.057659074 +0200
@@ -41,6 +41,6 @@ end
! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(5 - three.dim\\\[0\\\].lbound\\), &acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } }
! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(8 - three.dim\\\[0\\\].lbound\\), &ii, 0B, 0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\), &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, 1 - four.dim\\\[0\\\].lbound, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 2 - four.dim\\\[0\\\].lbound, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, .*\\(1 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - four.dim\\\[1\\\].lbound\\), &acquired.\[0-9\]+, &ii, 0B, 0\\);|_gfortran_caf_lock \\(four.token, \[^\n\r]*1 - four.dim\\\[0\\\].lbound\\)?, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, &ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, .*\\(2 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - four.dim\\\[1\\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, \[^\n\r]*2 - four.dim\\\[0\\\].lbound\\)?, 8 - four.dim\\\[1\\\].lbound, 0B, 0B, 0\\);" 1 "original" } }
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do array index calculations in gfc_array_index_type
2018-09-25 7:57 ` Jakub Jelinek
@ 2018-09-25 13:13 ` Janne Blomqvist
0 siblings, 0 replies; 7+ messages in thread
From: Janne Blomqvist @ 2018-09-25 13:13 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Kyrill Tkachov, Andreas Schwab, Fortran List, GCC Patches
On Tue, Sep 25, 2018 at 10:57 AM Jakub Jelinek <jakub@redhat.com> wrote:
> For -m64, the last lock/unlock are:
> _gfortran_caf_lock (four.token, (unsigned long) (1 -
> four.dim[0].lbound), (integer(kind=4)) (7 - four.dim[1].lbound),
> &acquired.11, &ii, 0B, 0);
> _gfortran_caf_unlock (four.token, (unsigned long) (2 -
> four.dim[0].lbound), (integer(kind=4)) (8 - four.dim[1].lbound), 0B, 0B, 0);
> while for -m32, the last lock/unlock are:
> _gfortran_caf_lock (four.token, (character(kind=4)) (1 -
> four.dim[0].lbound), 7 - four.dim[1].lbound, &acquired.11, &ii, 0B, 0);
> _gfortran_caf_unlock (four.token, (character(kind=4)) (2 -
> four.dim[0].lbound), 8 - four.dim[1].lbound, 0B, 0B, 0);
> The regexp expects either casts on both (which is why -m64 works), or no
> casts on either, but not the case when there is a cast just on the second
> argument and not on the third one.
>
> The following patch fixes it, tested with the above make check-gfortran.
>
> Note, there are still 4 spots that use .*, that looks dangerous to me, as
> it
> can match many lines. I'd suggest \[^\n\r]* instead.
>
> 2018-09-25 Jakub Jelinek <jakub@redhat.com>
>
> * gfortran.dg/coarray_lock_7.f90: Adjust scan-tree-dump-times for
> ILP32.
>
>
Thanks, Ok for trunk!
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-09-25 13:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-22 19:22 [PATCH] Do array index calculations in gfc_array_index_type Janne Blomqvist
2018-09-23 9:40 ` Paul Richard Thomas
2018-09-24 13:54 ` Andreas Schwab
2018-09-24 16:49 ` Kyrill Tkachov
2018-09-24 19:39 ` Janne Blomqvist
2018-09-25 7:57 ` Jakub Jelinek
2018-09-25 13:13 ` Janne Blomqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).