From patchwork Fri Jul 16 20:04:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 59122 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 4A296B6F14 for ; Sat, 17 Jul 2010 06:04:57 +1000 (EST) Received: (qmail 31962 invoked by alias); 16 Jul 2010 20:04:55 -0000 Received: (qmail 31800 invoked by uid 22791); 16 Jul 2010 20:04:53 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, 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, 16 Jul 2010 20:04:46 +0000 Received: from [192.168.0.197] (xdsl-213-168-119-61.netcologne.de [213.168.119.61]) by smtp5.netcologne.de (Postfix) with ESMTP id CCDEC40D075; Fri, 16 Jul 2010 22:04:41 +0200 (CEST) Subject: [Patch, RFC] gfc_* optimization pass for Fortran From: Thomas Koenig To: fortran@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Date: Fri, 16 Jul 2010 22:04:41 +0200 Message-ID: <1279310681.9566.6.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, here is an attempt at an optimization pass for Fortran based on gfc_* data structures. It adds a new file, optimize.c. Optimizations are only performed if the user specifies -O. Right now, the actual optimizations performed are few - it replaces comparisons of varaibles with themselves with .true. and strips off TRIM from string comparisons and assingments. This does not yet regtest cleanly. Comments? Is this the right approach? Other ideas? I'll add some test cases and a ChangeLog later, if the consensus is that this should go ahead. Thomas Index: Make-lang.in =================================================================== --- Make-lang.in (Revision 161930) +++ Make-lang.in (Arbeitskopie) @@ -66,7 +66,7 @@ fortran/trans.o fortran/trans-array.o fortran/trans-common.o \ fortran/trans-const.o fortran/trans-decl.o fortran/trans-expr.o \ fortran/trans-intrinsic.o fortran/trans-io.o fortran/trans-openmp.o \ - fortran/trans-stmt.o fortran/trans-types.o + fortran/trans-stmt.o fortran/trans-types.o fortran/optimize.o fortran_OBJS = $(F95_OBJS) gfortranspec.o Index: gfortran.h =================================================================== --- gfortran.h (Revision 161930) +++ gfortran.h (Arbeitskopie) @@ -2828,4 +2828,8 @@ #define CLASS_DATA(sym) sym->ts.u.derived->components +/* optimize.c */ + +void gfc_optimize_namespace (gfc_namespace *); + #endif /* GCC_GFORTRAN_H */ Index: trans-decl.c =================================================================== --- trans-decl.c (Revision 161930) +++ trans-decl.c (Arbeitskopie) @@ -4374,6 +4374,9 @@ int rank; bool is_recursive; + if (optimize) + gfc_optimize_namespace (ns); + sym = ns->proc_name; /* Check that the frontend isn't still using this. */