This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [GCC][PATCH][mid-end] Optimize x * copysign (1.0, y) [Patch (1/2)]
- From: Michael Meissner <meissner at linux dot vnet dot ibm dot com>
- To: Tamar Christina <Tamar dot Christina at arm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>, "law at redhat dot com" <law at redhat dot com>, "ian at airs dot com" <ian at airs dot com>, "rguenther at suse dot de" <rguenther at suse dot de>
- Date: Mon, 12 Jun 2017 15:50:51 -0400
- Subject: Re: [GCC][PATCH][mid-end] Optimize x * copysign (1.0, y) [Patch (1/2)]
- Authentication-results: sourceware.org; auth=none
- References: <VI1PR0801MB20316B7A94D73C180C266C15FFCD0@VI1PR0801MB2031.eurprd08.prod.outlook.com>
On Mon, Jun 12, 2017 at 07:56:54AM +0000, Tamar Christina 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.
>
> Ok for trunk?
Please only enable this if you have XORSIGN and XORSIGNF.
On the PowerPC this would involve moving the value from the vector/floating
point registers to the general purpose registers to do the XOR operation and
then back to the vector/floating point registers.
Note, the PowerPC has an instruction that does copysign directly. It would be
better just to do the copysign/multiply.
--
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797