From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1792 invoked by alias); 4 Nov 2010 06:18:22 -0000 Received: (qmail 1774 invoked by uid 22791); 4 Nov 2010 06:18:17 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_LB,TW_TM X-Spam-Check-By: sourceware.org Received: from mail-bw0-f47.google.com (HELO mail-bw0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Nov 2010 06:18:08 +0000 Received: by bwz10 with SMTP id 10so1325903bwz.20 for ; Wed, 03 Nov 2010 23:18:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.66.71 with SMTP id m7mr262556bki.32.1288851485218; Wed, 03 Nov 2010 23:18:05 -0700 (PDT) Received: by 10.204.23.3 with HTTP; Wed, 3 Nov 2010 23:18:05 -0700 (PDT) In-Reply-To: References: <20101009134002.157E83BE0F@mailhost.lps.ens.fr> <20101023202653.2DF9D3BE18@mailhost.lps.ens.fr> <4CC47A12.7050504@net-b.de> <20101031215043.8B69A3BE18@mailhost.lps.ens.fr> <20101101101824.F0F663BE18@mailhost.lps.ens.fr> <20101102222221.CB2BB3BE18@mailhost.lps.ens.fr> Date: Thu, 04 Nov 2010 08:46:00 -0000 Message-ID: Subject: Re: (Re)allocation of allocatable arrays on assignment - F2003 From: Paul Richard Thomas To: fortran@gcc.gnu.org, gcc-patches Cc: Tobias Burnus , Dominique Dhumieres Content-Type: multipart/mixed; boundary=001636c5abfaf1d96d0494341e8e Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-11/txt/msg00393.txt.bz2 --001636c5abfaf1d96d0494341e8e Content-Type: text/plain; charset=ISO-8859-1 Content-length: 3431 Dear All, I believe that this one is finally it! The bugs fixed are reflected in the second testcase. In particular, the bounds of the lhs are consistently calculated and even seem to be correct; which is more than can be said for other products. In addition to correcting bugs, the main addition to the patch is the option -f(no-)realloc_lhs. Default behaviour for -std > f95 is to reallocate on assignment. The option allows one to improve performance a bit for f200x and to benefit from the feature for f95. Tobias Burnus prepared this part of the patch. Please note that allocatable assignments of the kind: x = transformational_array_intrinisic (...) now produce a temporary unless -fno-realloc_lhs or -std=f95 are deployed. This could be fixed relatively easily by detecting the option in the library and repeating the logic of gfc_alloc_allocatable_for_assignment there. Bootstrapped and regtested on FC9/x86_64 - OK for trunk? (Richard, Jakub - please note the discussion on the gfortran list about the slightly late submission of this patch relative to the end of stage 1. A mostly cooked version was seen a week ago.) Many thanks to Tobias and Dominique for their help with this patch. Their testcases went places that no other cleaner goes :-) Cheers Paul 2010-11-04 Paul Thomas * trans-array.c (gfc_trans_array_constructor): If the loop->to is a VAR_DECL, assume this is dynamic. In this case, use the counter to obtain the value and set loop->to appropriately. (gfc_conv_ss_descriptor): Always save the offset of a variable in info.saved_offset. (gfc_conv_ss_startstride): Do not attempt bound checking of the lhs of an assignment, if allocatable and f2003 is allowed. (gfc_conv_loop_setup): If possible, do not use an allocatable lhs variable for the loopspec. (get_std_lbound): New function. (gfc_alloc_allocatable_for_assignment): New function. * gfortran.h : Add flag_realloc_lhs to the options structure. * lang.opt : Add option f(no-)realloc_lhs. * invoke.texi : Document option f(no-)realloc_lhs. * options.c (gfc_init_options, gfc_post_options, gfc_handle_option): Incorporate f(no-)realloc_lhs with default to frealloc_lhs for -std > f95. * trans-array.h : Add primitive for previous. * trans-expr.c (gfc_conv_procedure_call): If the call is of the kind x = f(...) and the lhs is allocatable and reallocation on assignment is OK, call gfc_alloc_allocatable_for_assignment. (arrayfunc_assign_needs_temporary): Reallocation assignments where the lhs is an intrinsic need a temporary. (gfc_trans_arrayfunc_assign): Reallocation assignments need a loopinfo and for the loop bounds to be set. (gfc_trans_assignment_1): If the lhs is allocatable and reallocation on assignment is allowed, mark the lhs and use gfc_alloc_allocatable_for_assignment to make the reallocation. * trans.h : Add is_alloc_lhs bitfield to gfc_ss structure. 2010-11-04 Paul Thomas