From patchwork Fri Mar 9 21:29:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 145762 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3EA9BB6EE8 for ; Sat, 10 Mar 2012 08:30:26 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1331933427; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=UYzrOo6 9znRSNQSWnwDUygm6oeo=; b=gqPxHjoCBK01dVFXGDmH8dpzGZLDYG3WlEeG2hm YIQ8AoIokhERi1JTu4wdwmoI1LJdY/ZIr1S07LWOS1WjN+nH7NmR8yTpVV7CW/iB ij5U5KqdJH+3kp96Xaq8ki/krZPmjkmZUgVNcm5tuLrmZnmUPU4DnQQTYz2JPUdO oDGs= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=H3LV+prjNTofPyS3beQdDKgRJJEsYwgrAnh00v6EjuX1/dK6wjKXKVKCHVA1UQ G61wx1G8W95IWvFwDoBCjmJe0LL0BaucmN2cvv2bbPyAn8cn7DOB5TE5dHnzbqaY srUXVJy9JUuvcZadKjhDPoIO54bIV0uKgxrAwXHYTB6n8=; Received: (qmail 22880 invoked by alias); 9 Mar 2012 21:30:16 -0000 Received: (qmail 22863 invoked by uid 22791); 9 Mar 2012 21:30:14 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Mar 2012 21:29:58 +0000 Received: from [192.168.178.22] (port-92-204-75-4.dynamic.qsc.de [92.204.75.4]) by mx02.qsc.de (Postfix) with ESMTP id B0F501DDCB; Fri, 9 Mar 2012 22:29:54 +0100 (CET) Message-ID: <4F5A7651.2010407@net-b.de> Date: Fri, 09 Mar 2012 22:29:53 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120215 Thunderbird/10.0.2 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Fortran-dev, Patch] Fix extent calculation, fix test suite failures Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Without the patch, I got some coarray failures (for -fcoarray=lib) and 425 other failures. With this patch, the number of failures is down to 269. I intent to commit the patch to the fortran-devel branch tomorrow, unless there are objection. Changes: * Fix offset for coarray's token field * Extent is in number of elements and not in bytes; fix setting of the compatibility fields * Set lbound before ubound as ubound uses lbound (plus extent). * For character namelist read: Also set extent (and sm) - used by UBOUND macro * Switch library's UBOUND/EXTENT macros to use only new fields rather than the old one. I think the front end should be mostly okay, but the library still accesses ubound directly - and for stride vs. sm: Well, "sm" is currently not set at all. As the element size is needed, it requires larger changes. I wouldn't be surprised if the remaining failures relate to sm and/or extent issues. Tobias Index: gcc/fortran/ChangeLog.fortran-dev =================================================================== --- gcc/fortran/ChangeLog.fortran-dev (Revision 185103) +++ gcc/fortran/ChangeLog.fortran-dev (Arbeitskopie) @@ -1,3 +1,14 @@ +2012-03-10 Tobias Burnus + + * trans-array.c (CAF_TOKEN_FIELD): Set to the correct value. + (gfc_conv_descriptor_ubound_get, gfc_conv_descriptor_ubound_set): + Remove bogus byte-size handling, correctly handle lower bounds + which don't start with unity. + (gfc_conv_shift_descriptor_lbound): Reorder to make sure that + lbound comes before ubound. + * trans-expr.c (gfc_conv_subref_array_arg, + gfc_trans_alloc_subarray_assign): Ditto. + 2010-09-01 Paul Thomas * trans-array.c : Define and subsequently undefine descriptor Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (Revision 185103) +++ gcc/fortran/trans-array.c (Arbeitskopie) @@ -130,7 +130,7 @@ gfc_array_dataptr_type (tree desc) #define DTYPE_FIELD 2 #define SIZE_FIELD 3 #define DIMENSION_FIELD 4 -#define CAF_TOKEN_FIELD 4 +#define CAF_TOKEN_FIELD 5 #define STRIDE_SUBFIELD 0 #define LBOUND_SUBFIELD 1 @@ -472,16 +472,13 @@ gfc_conv_descriptor_ubound (tree desc, tree dim) tree gfc_conv_descriptor_ubound_get (tree desc, tree dim) { - tree cond, size; - tree tmp = gfc_get_element_type (TREE_TYPE (desc)); - size = size_in_bytes (tmp); - size = fold_convert (gfc_array_index_type, size); - tmp = fold_build2_loc (input_location, FLOOR_DIV_EXPR, gfc_array_index_type, - gfc_conv_descriptor_extent_get (desc, dim), size); - cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, size, - gfc_index_zero_node); - tmp = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type, cond, - gfc_index_zero_node, tmp); + tree lb = gfc_conv_descriptor_lbound (desc, dim); + tree tmp = gfc_conv_descriptor_extent_get (desc, dim); + tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, + fold_convert (gfc_array_index_type, lb), + fold_convert (gfc_array_index_type, tmp)); + tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, + tmp, gfc_index_one_node); return tmp; } @@ -492,11 +489,12 @@ gfc_conv_descriptor_ubound_set (stmtblock_t *block tree tmp; tree t = gfc_conv_descriptor_ubound (desc, dim); gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value)); - tmp = gfc_get_element_type (TREE_TYPE (desc)); - tmp = size_in_bytes (tmp); - tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, - fold_convert (TREE_TYPE (t), value), + tmp = gfc_conv_descriptor_lbound (desc, dim); + tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, + fold_convert (TREE_TYPE (t), t), fold_convert (TREE_TYPE (t), tmp)); + tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, + tmp, gfc_index_one_node); gfc_conv_descriptor_extent_set (block, desc, dim, tmp); } @@ -542,19 +540,20 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* blo diff = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, new_lbound, lbound); - /* Shift ubound and offset accordingly. This has to be done before - updating the lbound, as they depend on the lbound expression! */ - ubound = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, - ubound, diff); - gfc_conv_descriptor_ubound_set (block, desc, gfc_rank_cst[dim], ubound); offs_diff = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, diff, stride); offs = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, offs, offs_diff); gfc_conv_descriptor_offset_set (block, desc, offs); - /* Finally set lbound to value we want. */ + /* Set lbound to value we want. */ gfc_conv_descriptor_lbound_set (block, desc, gfc_rank_cst[dim], new_lbound); + + /* Update ubound. As it uses internally lbound + extend, it has to be after + the lbound expression! */ + ubound = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, + ubound, diff); + gfc_conv_descriptor_ubound_set (block, desc, gfc_rank_cst[dim], ubound); } Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 185103) +++ gcc/fortran/trans-expr.c (Arbeitskopie) @@ -3153,14 +3153,14 @@ gfc_conv_subref_array_arg (gfc_se * parmse, gfc_ex tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, tmp, gfc_index_one_node); + gfc_conv_descriptor_lbound_set (&parmse->pre, + parmse->expr, + gfc_rank_cst[n], + gfc_index_one_node); gfc_conv_descriptor_ubound_set (&parmse->pre, parmse->expr, gfc_rank_cst[n], tmp); - gfc_conv_descriptor_lbound_set (&parmse->pre, - parmse->expr, - gfc_rank_cst[n], - gfc_index_one_node); size = gfc_evaluate_now (size, &parmse->pre); offset = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, @@ -5186,10 +5186,10 @@ gfc_trans_alloc_subarray_assign (tree dest, gfc_co 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_lbound_set (&block, dest, + gfc_rank_cst[n], lbound); gfc_conv_descriptor_ubound_set (&block, dest, gfc_rank_cst[n], tmp); - gfc_conv_descriptor_lbound_set (&block, dest, - gfc_rank_cst[n], lbound); tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, gfc_conv_descriptor_lbound_get (dest, Index: libgfortran/io/list_read.c =================================================================== --- libgfortran/io/list_read.c (Revision 185103) +++ libgfortran/io/list_read.c (Arbeitskopie) @@ -2894,7 +2894,10 @@ get_name: if (c == '(' && nl->type == BT_CHARACTER) { - descriptor_dimension chd[1] = { {1, clow, nl->string_length} }; +/* FIXME: Sets stride, lower_bound, _ubound, sm, extent, but extend + should be kind dependent. Cf. also PR 52539. */ + descriptor_dimension chd[1] = { {1, clow, nl->string_length, 1, + nl->string_length - clow + 1} }; array_loop_spec ind[1] = { {1, clow, nl->string_length, 1} }; if (nml_parse_qualifier (dtp, chd, ind, -1, nml_err_msg, Index: libgfortran/libgfortran.h =================================================================== --- libgfortran/libgfortran.h (Revision 185103) +++ libgfortran/libgfortran.h (Arbeitskopie) @@ -369,16 +369,9 @@ typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, #define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype) #define GFC_DIMENSION_LBOUND(dim) ((dim).lower_bound) -/* Old. */ -#define GFC_DIMENSION_UBOUND(dim) ((dim)._ubound) -#define GFC_DIMENSION_EXTENT(dim) ((dim).ubound + 1 - (dim).lower_bound) +#define GFC_DIMENSION_UBOUND(dim) ((dim).lower_bound + (dim).extent - 1) +#define GFC_DIMENSION_EXTENT(dim) ((dim).extent) -/* New. */ -/* - #define GFC_DIMENSION_UBOUND(dim) ((dim).lower_bound + (dim).extent - 1) - #define GFC_DIMENSION_EXTENT(dim) ((dim).extent) -*/ - #define GFC_DIMENSION_SET(dim,lb,ub,str) \ do \ { \ Index: libgfortran/ChangeLog.fortran-dev =================================================================== --- libgfortran/ChangeLog.fortran-dev (Revision 185103) +++ libgfortran/ChangeLog.fortran-dev (Arbeitskopie) @@ -1,3 +1,9 @@ +2012-03-10 Tobias Burnus + + * libgfortran.h (GFC_DIMENSION_UBOUND, GFC_DIMENSION_EXTENT): + Use extent and lower_bound internally. + * io/list_read.c (nml_get_obj_data): Set also sm and extent. + 2012-03-06 Tobias Burnus * ISO_Fortran_binding.h: New.