From patchwork Fri Oct 22 14:03:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 68857 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 4EE1FB6EE9 for ; Sat, 23 Oct 2010 01:04:08 +1100 (EST) Received: (qmail 22813 invoked by alias); 22 Oct 2010 14:04:05 -0000 Received: (qmail 22797 invoked by uid 22791); 22 Oct 2010 14:04:04 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Oct 2010 14:03:57 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id C966C8765C; Fri, 22 Oct 2010 16:03:54 +0200 (CEST) Date: Fri, 22 Oct 2010 16:03:54 +0200 (CEST) From: Richard Guenther To: Richard Henderson Cc: "Joseph S. Myers" , Michael Meissner , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Add FMA_EXPR, un-cse multiplications before expansion In-Reply-To: <4CC19312.3070207@redhat.com> Message-ID: References: <20101021233257.GB3097@hungry-tiger.westford.ibm.com> <4CC19312.3070207@redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) 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 On Fri, 22 Oct 2010, Richard Henderson wrote: > On 10/21/2010 05:09 PM, Joseph S. Myers wrote: > > My model is that the .md files always accurately describe the instructions > > - using fma RTL, not (a*b)+c RTL - at which point the insns should be > > conditioned on the instructions actually being available, not on the > > -ffp-contract setting. > > With the exception of s390 and arm, I believe the backends have been > converted so that the fma rtl pattern is available. However, the > existing backend switch -mfused-madd (TARGET_FUSED_MADD) is still > supported via a*b+c rtl. > > I would be absolutely delighted if we could drop/alias the -m switch > to a generic -f switch that can handle this in either combine or in > Richi's new pass. Consider the following added to my patch. Note that for the mul/add patterns to be removed we have to address the fma expander pattern issue I raised in the original posting (the expander doesn't like (fma (mul (neg x) y) z) yet and so the neg gets split away and optimized by its expander confusing combine). Joseph, I'm waiting for your last option handling patch to go in to adjust -ffast-math to include -ffp-contract. I'm also not sure how to do the tristate on/off/fast at the moment. Richard. Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c.orig 2010-10-22 16:00:28.000000000 +0200 +++ gcc/tree-ssa-math-opts.c 2010-10-22 16:00:22.000000000 +0200 @@ -1507,6 +1507,10 @@ convert_mult_to_fma (gimple mul_stmt) use_operand_p use_p; imm_use_iterator imm_iter; + if (FLOAT_TYPE_P (type) + && !flag_fp_contract) + return false; + /* If the target doesn't support it, don't generate it. ??? We have no way of querying support for the various variants with negated operands, so for the following we simply assume Index: gcc/common.opt =================================================================== --- gcc/common.opt.orig 2010-10-14 14:00:03.000000000 +0200 +++ gcc/common.opt 2010-10-22 15:58:37.000000000 +0200 @@ -842,6 +842,10 @@ fforward-propagate Common Report Var(flag_forward_propagate) Optimization Perform a forward propagation pass on RTL +ffp-contract +Common Report Var(flag_fp_contract) Optimization +Perform floating-point expression contraction. + ; Nonzero means don't put addresses of constant functions in registers. ; Used for compiling the Unix kernel, where strange substitutions are ; done on the assembly output.