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] Optimize x * copysign (1.0, y) [Patch (1/2)]


> > It should be a match.pd rule that uses a match predicate, so expand in
> > gimple-match.c. but don't do this if the target doesn't have the
> > xorsign optab and don't do it if honouring SNAN.
> 
> Note that this will trigger too early (IMHO), so unless you feel like inventing
> new infrastructure I'd put manual pattern matching in tree-ssa-math-opts.c
> pass_optimize_widening_mul where we currently do this kind of "late
> GIMPLE instruction selection".
> 

Alright, I'll do that then, thanks!

> Richard.
> 
> > I'll make the changes then.
> > Thanks,
> > Tamar
> >
> > >
> > > Think of a combine pass combining GIMPLE stmts to (recognized) RTL
> > > insn (sequences).  Until RTL expansion the RTL insn (sequence) would
> > > be represented by an internal function call (or alternatively for
> > > multi-output cases an GIMPLE ASM with enumerated asm text).
> > >
> > > Richard.
> > >
> > > > > Thanks,
> > > > > Richard.
> > > > >
> > > > > >
> > > > > > gcc/
> > > > > > 2017-07-10  Tamar Christina  <tamar.christina@arm.com>
> > > > > > 	    Andrew Pinski <pinskia@gmail.com>
> > > > > >
> > > > > > 	PR middle-end/19706
> > > > > > 	* expr.c (is_copysign_call_with_1): New.
> > > > > > 	(maybe_expand_mult_copysign): Likewise.
> > > > > > 	(expand_expr_real_2): Expand copysign.
> > > > > > 	* optabs.def (xorsign_optab): New.
> > > > > >
> > > > > > ________________________________________
> > > > > > From: Andrew Pinski <pinskia@gmail.com>
> > > > > > Sent: Monday, July 10, 2017 12:21:29 AM
> > > > > > To: Tamar Christina
> > > > > > Cc: GCC Patches; nd; law@redhat.com; ian@airs.com;
> > > > > > rguenther@suse.de
> > > > > > Subject: Re: [GCC][PATCH][mid-end] Optimize x * copysign (1.0,
> > > > > > y) [Patch (1/2)]
> > > > > >
> > > > > > On Mon, Jun 12, 2017 at 12:56 AM, Tamar Christina
> > > > > > <Tamar.Christina@arm.com> wrote:
> > > > > > > Hi All,
> > > > > > >
> > > > > > > this patch implements a optimization rewriting
> > > > > > >
> > > > > > > x * copysign (1.0, y) and
> > > > > > > x * copysign (-1.0, y)
> > > > > > >
> > > > > > > to:
> > > > > > >
> > > > > > > x ^ (y & (1 << sign_bit_position))
> > > > > > >
> > > > > > > This is done by creating a special builtin during matching
> > > > > > > and generate the appropriate instructions during expand.
> > > > > > > This new builtin is
> > > > > called XORSIGN.
> > > > > > >
> > > > > > > The expansion of xorsign depends on if the backend has an
> > > > > > > appropriate optab available. If this is not the case then we
> > > > > > > use a modified version of the existing copysign which does
> > > > > > > not take the abs
> > > > > value of the first argument as a fall back.
> > > > > > >
> > > > > > > This patch is a revival of a previous patch
> > > > > > > https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00069.html
> > > > > > >
> > > > > > > Bootstrapped on both aarch64-none-linux-gnu and x86_64 with
> > > > > > > no
> > > > > issues.
> > > > > > > Regression done on aarch64-none-linux-gnu and no regressions.
> > > > > >
> > > > > >
> > > > > > Note this is also PR 19706.
> > > > > >
> > > > > > Thanks,
> > > > > > Andrew
> > > > > >
> > > > > > >
> > > > > > > Ok for trunk?
> > > > > > >
> > > > > > > gcc/
> > > > > > > 2017-06-07  Tamar Christina  <tamar.christina@arm.com>
> > > > > > >
> > > > > > >         * builtins.def (BUILT_IN_XORSIGN, BUILT_IN_XORSIGNF):
> New.
> > > > > > >         (BUILT_IN_XORSIGNL, BUILT_IN_XORSIGN_FLOAT_NX):
> > > Likewise.
> > > > > > >         * match.pd (mult (COPYSIGN:s real_onep @0) @1): New
> > > simplifier.
> > > > > > >         (mult (COPYSIGN:s real_mus_onep @0) @1): Likewise.
> > > > > > >         (copysigns @0 (negate @1)): Likewise.
> > > > > > >         * builtins.c (expand_builtin_copysign): Promoted
> > > > > > > local to
> > > argument.
> > > > > > >         (expand_builtin): Added CASE_FLT_FN_FLOATN_NX
> > > > > (BUILT_IN_XORSIGN) and
> > > > > > >         CASE_FLT_FN (BUILT_IN_XORSIGN).
> > > > > > >         (BUILT_IN_COPYSIGN): Updated function call.
> > > > > > >         * optabs.h (expand_copysign): New bool.
> > > > > > >         (expand_xorsign): New.
> > > > > > >         * optabs.def (xorsign_optab): New.
> > > > > > >         * optabs.c (expand_copysign): New parameter.
> > > > > > >         * fortran/f95-lang.c (xorsignl, xorsign, xorsignf): New.
> > > > > > >         * fortran/mathbuiltins.def (XORSIGN): New.
> > > > > > >
> > > > > > > gcc/testsuite/
> > > > > > > 2017-06-07  Tamar Christina  <tamar.christina@arm.com>
> > > > > > >
> > > > > > >         * gcc.dg/tree-ssa/xorsign.c: New.
> > > > > > >         * gcc.dg/xorsign_exec.c: New.
> > > > > > >         * gcc.dg/vec-xorsign_exec.c: New.
> > > > > > >         * gcc.dg/tree-ssa/reassoc-39.c (f2, f3): Updated constant to 2.
> > > > > >
> > > > >
> > > > > --
> > > > > 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)
> >
> >
> 
> --
> 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]