From patchwork Mon Mar 10 10:20:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Bolton X-Patchwork-Id: 328528 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B1572C00A5 for ; Mon, 10 Mar 2014 21:20:19 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=uJAsURCI2gotqzcBUflNzjX/jJo8k814VB6jchjzilWoCVeqId5RJ sCiQDDDFjZHTFyV49a1XKYp//W5PV29wI6VICteKkIfIAbaHPEZbInDAwKUotFvv pey+KTqobDlNYzXbbSZ62sm1W97380MBqg74MCOq89dDewnYQYrm0Q= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=j+kM53jUnolJmqZy3qTf+NCcWr8=; b=YbHfXv7zdnxWITL+vBxP hVmohO2GbGMIwJ+oXJDD0+zliSeIWJPGaZq+matUh+sLehxFnwCv6zyMIJlnlBqN xM957GmWzM8fJ8pVAMAqJQDHaB8jYz5TkI9HSF1KYEJwGofmFflrQviwKfwc2m9L L6zRKRT+5b4CApEnDovHcls= Received: (qmail 13109 invoked by alias); 10 Mar 2014 10:20:12 -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 13097 invoked by uid 89); 10 Mar 2014 10:20:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_20, MSGID_MULTIPLE_AT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Mar 2014 10:20:11 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 10 Mar 2014 10:20:08 +0000 Received: from e104535vm ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 10 Mar 2014 10:20:08 +0000 From: "Ian Bolton" To: Subject: [PATCH] Keep -ffp-contract=fast by default if we have -funsafe-math-optimizations Date: Mon, 10 Mar 2014 10:20:13 -0000 Message-ID: <000301cf3c4a$5328c120$f97a4360$@bolton@arm.com> MIME-Version: 1.0 X-MC-Unique: 114031010200800501 X-IsSubscribed: yes Hi, In common.opt, -ffp-contract=fast is set as the default for GCC. But then it gets disabled in c-family/c-opts.c if you are using ISO C (e.g. with -std=c99). The reason for this patch is that if you have also specified -funsafe-math-optimizations (or -Ofast or -ffast-math) then it is likely your preference to have -ffp-contract=fast on, so you can generate fused multiply adds (fma standard pattern). This patch works by blocking the override if you have -funsafe-math-optimizations (directly or indirectly), causing fused multiply add to be used in the places where we might hope to see it. (I had considered forcing -ffp-contract=fast on in opts.c if you have -funsafe-math-optimizations, but it is already on by default ... and it didn't work either! The problem is that it is forced off unless you have explicitly asked for -ffp-contract=fast at the command-line.) Standard regressions passed. OK for trunk or stage 1? Cheers, Ian 10-03-2014 Ian Bolton * gcc/c-family/c-opts.c (c_common_post_options): Don't override -ffp-contract=fast if unsafe-math-optimizations is on. diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index b7478f3..92ba481 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -834,7 +834,8 @@ c_common_post_options (const char **pfilename) if (flag_iso && !c_dialect_cxx () && (global_options_set.x_flag_fp_contract_mode - == (enum fp_contract_mode) 0)) + == (enum fp_contract_mode) 0) + && flag_unsafe_math_optimizations == 0) flag_fp_contract_mode = FP_CONTRACT_OFF; /* By default we use C99 inline semantics in GNU99 or C99 mode. C99