From patchwork Wed May 4 12:00:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 94011 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 92F931007D1 for ; Wed, 4 May 2011 22:00:50 +1000 (EST) Received: (qmail 5964 invoked by alias); 4 May 2011 12:00:47 -0000 Received: (qmail 5918 invoked by uid 22791); 4 May 2011 12:00:43 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 May 2011 12:00:28 +0000 Received: from [192.168.178.22] (port-92-204-45-85.dynamic.qsc.de [92.204.45.85]) by mx02.qsc.de (Postfix) with ESMTP id A023C1E362; Wed, 4 May 2011 14:00:25 +0200 (CEST) Message-ID: <4DC13FD7.10402@net-b.de> Date: Wed, 04 May 2011 14:00:23 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran+gcc/doc/invoke.texi] PR48864: -Ofast implies -fno-protect parens 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 As the example in the PR shows, using -fno-protect parens can make a huge difference. As -fno-protect is in the spirit of -Ofast, enable it with that option. Build on x86-64-linux. OK for the trunk? Tobias gcc/ 2011-05-04 Tobias Burnus PR fortran/48864 * doc/invoke.texi (Ofast): Document that it enables Fortran's -fno-protect-parens. gcc/fortran 2011-05-04 Tobias Burnus PR fortran/48864 * invoke.texi (fno-protect-parens): Document that -Ofast implies -fno-protect-parens. * options.c (gfc_init_options, gfc_post_options): Make -Ofast imply -fno-protect-parens. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 8602923..9e27653 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -5999,7 +5999,8 @@ optimizations designed to reduce code size. Disregard strict standards compliance. @option{-Ofast} enables all @option{-O3} optimizations. It also enables optimizations that are not valid for all standard compliant programs. -It turns on @option{-ffast-math}. +It turns on @option{-ffast-math} and the Fortran-specific +@option{-fno-protect-parens}. If you use multiple @option{-O} options, with or without level numbers, the last such option is the one that is effective. diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 0874e5c..d24c2f2 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -1488,7 +1488,8 @@ levels such that the compiler does not do any re-association. Using @option{-fno-protect-parens} allows the compiler to reorder @code{REAL} and @code{COMPLEX} expressions to produce faster code. Note that for the re-association optimization @option{-fno-signed-zeros} and @option{-fno-trapping-math} -need to be in effect. +need to be in effect. The parentheses protection is enabled by default, unless +@option{-Ofast} is given. @item -frealloc-lhs @opindex @code{frealloc-lhs} diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index f56fad7..52422b1 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -151,7 +151,7 @@ gfc_init_options (unsigned int decoded_options_count, gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF; gfc_option.flag_init_character_value = (char)0; gfc_option.flag_align_commons = 1; - gfc_option.flag_protect_parens = 1; + gfc_option.flag_protect_parens = -1; gfc_option.flag_realloc_lhs = -1; gfc_option.flag_aggressive_function_elimination = 0; gfc_option.flag_frontend_optimize = -1; @@ -272,6 +272,9 @@ gfc_post_options (const char **pfilename) if (flag_associative_math == -1) flag_associative_math = (!flag_trapping_math && !flag_signed_zeros); + if (gfc_option.flag_protect_parens == -1) + gfc_option.flag_protect_parens = optimize_fast ? 0 : 1; + /* By default, disable (re)allocation during assignment for -std=f95, and enable it for F2003/F2008/GNU/Legacy. */ if (gfc_option.flag_realloc_lhs == -1)