From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6711 invoked by alias); 27 Oct 2011 23:34:17 -0000 Received: (qmail 24905 invoked by uid 22791); 27 Oct 2011 23:32:23 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,TW_TM X-Spam-Check-By: sourceware.org Received: from smtp25.services.sfr.fr (HELO smtp25.services.sfr.fr) (93.17.128.120) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Oct 2011 23:32:04 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id 6B2E1700004E; Fri, 28 Oct 2011 01:32:03 +0200 (CEST) Received: from gimli.local (145.15.72.86.rev.sfr.net [86.72.15.145]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id 02ED170000AC; Fri, 28 Oct 2011 01:32:02 +0200 (CEST) X-SFR-UUID: 20111027233203121.02ED170000AC@msfrf2512.sfr.fr Content-Type: multipart/mixed; boundary="===============1848169449803867546==" MIME-Version: 1.0 From: Mikael Morin To: gfortran , GCC patches Message-ID: <20111027233202.18581.15831@gimli.local> In-Reply-To: <20111027233144.18581.30688@gimli.local> References: <20111027232818.18581.901@gimli.local> <20111027233144.18581.30688@gimli.local> Subject: [Patch, fortran] [33/66] inline sum and product: Update the scalarizer. Date: Thu, 27 Oct 2011 23:35:00 -0000 X-IsSubscribed: yes 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: 2011-10/txt/msg02547.txt.bz2 --===============1848169449803867546== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-length: 665 gfc_trans_create_temp_array has code like this: for (n = 0; n < loop->dimen; n++) { if (size == NULL) { /* blah */ continue; } /* bleh */ } We are going to update this to handle more than one loop. However the two branches will get different treatments (see patches 45 and 46), so we can't keep one single for loop for both branches. This patch changes the code into: if (size == NULL) { for (n = 0; n < loop->dimen; n++) { /* blah */ } } else { for (n = 0; n < loop->dimen; n++ { /* bleh */ } } Context diff with blank spaces ignored also attached. OK? --===============1848169449803867546== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-33.CL" Content-length: 151 2011-10-19 Mikael Morin * trans-array.c (gfc_trans_create_temp_array): Move invariant condition out of the containing loop. --===============1848169449803867546== Content-Type: text/x-diff; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-33.patch" Content-length: 2954 diff --git a/trans-array.c b/trans-array.c index 545f2fb..663d12e 100644 --- a/trans-array.c +++ b/trans-array.c @@ -961,12 +961,12 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, break; } - for (n = 0; n < loop->dimen; n++) + if (size == NULL_TREE) { - dim = ss->dim[n]; - - if (size == NULL_TREE) + for (n = 0; n < loop->dimen; n++) { + dim = ss->dim[n]; + /* For a callee allocated array express the loop bounds in terms of the descriptor fields. */ tmp = fold_build2_loc (input_location, @@ -974,39 +974,42 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]), gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim])); loop->to[n] = tmp; - continue; } - - /* Store the stride and bound components in the descriptor. */ - gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size); + } + else + { + for (n = 0; n < loop->dimen; n++) + { + /* Store the stride and bound components in the descriptor. */ + gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size); - gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n], - gfc_index_zero_node); + gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n], + gfc_index_zero_node); - gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n], - to[n]); + gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n], to[n]); - tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, - to[n], gfc_index_one_node); + tmp = fold_build2_loc (input_location, PLUS_EXPR, + gfc_array_index_type, + to[n], gfc_index_one_node); - /* Check whether the size for this dimension is negative. */ - cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, tmp, - gfc_index_zero_node); - cond = gfc_evaluate_now (cond, pre); + /* Check whether the size for this dimension is negative. */ + cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, + tmp, gfc_index_zero_node); + cond = gfc_evaluate_now (cond, pre); - if (n == 0) - or_expr = cond; - else - or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR, - boolean_type_node, or_expr, cond); + if (n == 0) + or_expr = cond; + else + or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR, + boolean_type_node, or_expr, cond); - size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, - size, tmp); - size = gfc_evaluate_now (size, pre); + size = fold_build2_loc (input_location, MULT_EXPR, + gfc_array_index_type, size, tmp); + size = gfc_evaluate_now (size, pre); + } } /* Get the size of the array. */ - if (size && !callee_alloc) { /* If or_expr is true, then the extent in at least one --===============1848169449803867546== Content-Type: text/x-diff; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-33.diff" Content-length: 3645 diff --git a/trans-array.c b/trans-array.c index 545f2fb21a90c09ee439ae3f56656317b18eeb0a..663d12e6e6925b0d458ccbb1558204b46249f482 100644 *** a/trans-array.c --- b/trans-array.c *************** gfc_trans_create_temp_array (stmtblock_t *** 961,972 **** break; } for (n = 0; n < loop->dimen; n++) { dim = ss->dim[n]; - if (size == NULL_TREE) - { /* For a callee allocated array express the loop bounds in terms of the descriptor fields. */ tmp = fold_build2_loc (input_location, --- 961,972 ---- break; } + if (size == NULL_TREE) + { for (n = 0; n < loop->dimen; n++) { dim = ss->dim[n]; /* For a callee allocated array express the loop bounds in terms of the descriptor fields. */ tmp = fold_build2_loc (input_location, *************** gfc_trans_create_temp_array (stmtblock_t *** 974,997 **** gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]), gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim])); loop->to[n] = tmp; - continue; } ! /* Store the stride and bound components in the descriptor. */ gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size); gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n], gfc_index_zero_node); ! gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n], ! to[n]); ! tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, to[n], gfc_index_one_node); /* Check whether the size for this dimension is negative. */ ! cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, tmp, ! gfc_index_zero_node); cond = gfc_evaluate_now (cond, pre); if (n == 0) --- 974,1000 ---- gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]), gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim])); loop->to[n] = tmp; } ! } ! else ! { ! for (n = 0; n < loop->dimen; n++) ! { /* Store the stride and bound components in the descriptor. */ gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size); gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n], gfc_index_zero_node); ! gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n], to[n]); ! tmp = fold_build2_loc (input_location, PLUS_EXPR, ! gfc_array_index_type, to[n], gfc_index_one_node); /* Check whether the size for this dimension is negative. */ ! cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, ! tmp, gfc_index_zero_node); cond = gfc_evaluate_now (cond, pre); if (n == 0) *************** gfc_trans_create_temp_array (stmtblock_t *** 1000,1012 **** or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR, boolean_type_node, or_expr, cond); ! size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, ! size, tmp); size = gfc_evaluate_now (size, pre); } /* Get the size of the array. */ - if (size && !callee_alloc) { /* If or_expr is true, then the extent in at least one --- 1003,1015 ---- or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR, boolean_type_node, or_expr, cond); ! size = fold_build2_loc (input_location, MULT_EXPR, ! gfc_array_index_type, size, tmp); size = gfc_evaluate_now (size, pre); } + } /* Get the size of the array. */ if (size && !callee_alloc) { /* If or_expr is true, then the extent in at least one --===============1848169449803867546==--