On 08/11/15 15:04, Thomas Schwinge wrote:
Hi!
On Thu, 5 Nov 2015 10:48:02 -0500, Nathan Sidwell<nat...@acm.org> wrote:
>On 11/04/15 05:02, Bernd Schmidt wrote:
> >On 11/02/2015 02:56 PM, Nathan Sidwell wrote:
> >>On 10/28/15 14:40, Nathan Sidwell wrote:
> >>>Richard,
> >>>this patch adds folding for the new GOACC_DIM_POS and GOACC_DIM_SIZE
> >>>internal
> >>>functions. IIUC gimple_fold_call is the right place to add this.
> >>>
> >>>The size of a compute dimension is very often a compile-time
> >>>constant. On the
> >>>host, in particular it's 1, which means we can deduce the POS must be
> >>>zero.
>This is what I committed, using the helpers I recently added. (I realized we
can
>only get here for functions with the oacc attribute already set)
>--- gimple-fold.c (revision 229809)
>+++ gimple-fold.c (working copy)
>+/* Transform IFN_GOACC_DIM_SIZE and IFN_GOACC_DIM_POS internal
>+ function calls to constants, where possible. */
>+
>+static tree
>+fold_internal_goacc_dim (const gimple *call)
>+{
>+ int axis = get_oacc_ifn_dim_arg (call);
>+ int size = get_oacc_fn_dim_size (current_function_decl, axis);
>+ bool is_pos = gimple_call_internal_fn (call) == IFN_GOACC_DIM_POS;
>+ tree result = NULL_TREE;
>+
>+ /* If the size is 1, or we only want the size and it is not dynamic,
>+ we know the answer. */
>+ if (size == 1 || (!is_pos && size))
>+ {
>+ tree type = TREE_TYPE (gimple_call_lhs (call));
>+ result = build_int_cst (type, size - is_pos);
>+ }
>+
>+ return result;
>+}
>@@ -3106,6 +3129,10 @@ gimple_fold_call (gimple_stmt_iterator *
> return true;
> }
> break;
>+ case IFN_GOACC_DIM_SIZE:
>+ case IFN_GOACC_DIM_POS:
>+ result = fold_internal_goacc_dim (stmt);
>+ break;
Merging this into gomp-4_0-branch, we'd run into a lot of regressions
(for OpenACC kernels construct), for example:
[...]/source-gcc/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c: In
function 'main._omp_fn.0':
[...]/source-gcc/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c:8:0:
internal compiler error: Segmentation fault
0xac387f crash_signal
[...]/source-gcc/gcc/toplev.c:336
0x9b8399 tree_int_cst_elt_check
[...]/source-gcc/gcc/tree.h:3129
0x9b8399 get_oacc_fn_dim_size(tree_node*, int)
[...]/source-gcc/gcc/omp-low.c:12630
0x86c530 fold_internal_goacc_dim
[...]/source-gcc/gcc/gimple-fold.c:2917
0x86c530 gimple_fold_call
[...]/source-gcc/gcc/gimple-fold.c:3134
0x86dfe4 fold_stmt_1
[...]/source-gcc/gcc/gimple-fold.c:3702
0xbf9953 execute
[...]/source-gcc/gcc/tree-ssa-forwprop.c:2310
The dims in gcc/omp-low.c:get_oacc_fn_dim_size don't have values set, so
the "TREE_INT_CST_LOW (TREE_VALUE (dims))" fails. I have not analyzed
what exactly is going wrong; I just figured out that it's related to the
IFN_GOACC_DIM_POS without LHS usage that Tom introduced in
gomp-4_0-branch r228735 for OpenACC kernels to "neuter gang-single code
in gang-redundant mode",
<http://news.gmane.org/find-root.php?message_id=%3C561C1336.2050401%40mentor.com%3E>.
I've just removed that (
https://gcc.gnu.org/ml/gcc-patches/2015-11/msg00847.html ).
Thanks,
- Tom