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: [GCC][PATCH][mid-end][Version 3] Optimize x * copysign (1.0, y) [Patch (1/2)]


On Mon, 7 Aug 2017, Tamar Christina wrote:

> Hi Richard,
> 
> >               switch (code)
> >                 {
> >                 case MULT_EXPR:
> >                   if (!convert_mult_to_widen (stmt, &gsi)
> >                       && !convert_expand_mult_copysign (stmt, &gsi)
> >                       && convert_mult_to_fma (stmt,
> >                                               gimple_assign_rhs1 (stmt),
> >                                               gimple_assign_rhs2 (stmt)))
> > 
> > given you likely do not want x * copysign (1, y) + z to be transformed into
> > FMA but still use xorsign?
> 
> Ah yes, that's correct, thanks!
> 
> > 
> > I am also eventually missing a single-use check on the copysign result.  If the
> > result of copysign is used in multiple places do we want to keep the multiply
> > or is the xorsign much cheaper?
> > The only eventual disadvantage would be higher register pressure if y and
> > copysing (1, y) were not live at the same time before.
> 
> No the transformation should be limited for single use, I've updated the patch accordingly.

+static bool
+is_copysign_call_with_1 (gimple *call)
+{
+  gcall *c = dyn_cast <gcall *> (call);
+  if (! c)
+    return false;
+
+  enum combined_fn code = gimple_call_combined_fn (call);

use c instead of call.

Ok with that change.

Thanks,
Richard.

> Thanks,
> Tamar
> 
> > 
> > 
> > > gcc/
> > > 2017-08-03  Tamar Christina  <tamar.christina@arm.com>
> > > 	    Andrew Pinski <pinskia@gmail.com>
> > >
> > > 	PR middle-end/19706
> > > 	* internal-fn.def (XORSIGN): New.
> > > 	* optabs.def (xorsign_optab): New.
> > > 	* tree-ssa-math-opts.c (is_copysign_call_with_1): New.
> > > 	(convert_expand_mult_copysign): New.
> > > 	(pass_optimize_widening_mul::execute): Call
> > convert_expand_mult_copysign.
> > >
> > >
> > 
> > --
> > Richard Biener <rguenther@suse.de>
> > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton,
> > HRB 21284 (AG Nuernberg)
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]