This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add FMA_EXPR, un-cse multiplications before expansion


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/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.
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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]