From patchwork Fri Sep 3 20:54:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 63725 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 DCE6DB7157 for ; Sat, 4 Sep 2010 06:54:52 +1000 (EST) Received: (qmail 2111 invoked by alias); 3 Sep 2010 20:54:49 -0000 Received: (qmail 2095 invoked by uid 22791); 3 Sep 2010 20:54:48 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp5.netcologne.de (HELO smtp5.netcologne.de) (194.8.194.25) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Sep 2010 20:54:42 +0000 Received: from [192.168.0.196] (xdsl-87-79-58-248.netcologne.de [87.79.58.248]) by smtp5.netcologne.de (Postfix) with ESMTP id 8428831C1EF; Fri, 3 Sep 2010 22:54:39 +0200 (CEST) Subject: [patch, fortran] Front-end optimizations for contained namespaces From: Thomas Koenig To: fortran@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Date: Fri, 03 Sep 2010 22:54:39 +0200 Message-ID: <1283547279.4759.3.camel@linux-fd1f.site> Mime-Version: 1.0 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 Hello world, this patch makes sure that front-end optimizations are also applied to contained procedures. Regression-tested. OK for trunk? Thomas 2010-09-03 Thomas Koenig * dump_parse_tree (gfc_run_passes): Call optimize_namespace instead of optimize_code. (optimize_namespace): New function. 2010-09-03 Thomas Koenig * gfortran.dg/trim_optimize_2.f90: New test. Index: frontend-passes.c =================================================================== --- frontend-passes.c (Revision 163835) +++ frontend-passes.c (Arbeitskopie) @@ -28,6 +28,7 @@ /* Forward declarations. */ static void strip_function_call (gfc_expr *); +static void optimize_namespace (gfc_namespace *); static void optimize_assignment (gfc_code *); static void optimize_expr_0 (gfc_expr *); static bool optimize_expr (gfc_expr *); @@ -41,13 +42,24 @@ optimization pass is run. */ void -gfc_run_passes (gfc_namespace * ns) +gfc_run_passes (gfc_namespace *ns) { if (optimize) - optimize_code (ns->code); + optimize_namespace (ns); } +/* Optimize a namespace, including all contained namespaces. */ + static void +optimize_namespace (gfc_namespace *ns) +{ + optimize_code (ns->code); + + for (ns = ns->contained; ns; ns = ns->sibling) + optimize_namespace (ns); +} + +static void optimize_code (gfc_code *c) { for (; c; c = c->next)