From patchwork Mon Apr 29 22:29:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 240524 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 144BD2C00A6 for ; Tue, 30 Apr 2013 08:29:46 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=mA7uUsdBIw8DjgOs/8sA6+R+5NtE/xFG4D/ryrXFiSq7PV hu/xsWE8IP3Kp87WNDr4hDWqHZSrFjsE7tz3TnAROaKs1bwgEpWwKm/rdALQU3SE bFX9W7vcuWdaE0qGiXcs+R+qXfm3huU/o5JRpS7Fu+glIZqkel0IsV8c/Spck= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=6s6luiH4I9VzFInkPtiH+opGUcU=; b=YCDUajL1j6Y3SbH6Vq/1 GXBcc80VkRB/1JRXRf2uEK33xUkaTH/h3oGzGTSVgEkj+UoJDv4eRisHw0WcVu6b 328T028Vtugs16HdmfsHzlpaiEQ4yPaVJkg9BWheH5NnGbZ15kGW/Nd5Iw76SKCV UiGT/k9ow4QdPLJr/uJZl24= Received: (qmail 27963 invoked by alias); 29 Apr 2013 22:29:39 -0000 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 Received: (qmail 27946 invoked by uid 89); 29 Apr 2013 22:29:38 -0000 X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_LB autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 29 Apr 2013 22:29:37 +0000 Received: from archimedes.net-b.de (port-92-195-76-58.dynamic.qsc.de [92.195.76.58]) by mx02.qsc.de (Postfix) with ESMTP id 316A327849; Tue, 30 Apr 2013 00:29:34 +0200 (CEST) Message-ID: <517EF44E.5080600@net-b.de> Date: Tue, 30 Apr 2013 00:29:34 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Fortran-Dev] Some ubounds -> extent changes X-Virus-Found: No 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 * 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; }