This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PATCH] Fold (a > 0 ? 1.0 : -1.0) into copysign (1.0, a) and a * copysign (1.0, a) into abs(a)
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org,Tamar Christina <Tamar dot Christina at arm dot com>,Andrew Pinski <pinskia at gmail dot com>,GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: nd <nd at arm dot com>
- Date: Tue, 27 Jun 2017 16:56:56 +0200
- Subject: RE: [PATCH] Fold (a > 0 ? 1.0 : -1.0) into copysign (1.0, a) and a * copysign (1.0, a) into abs(a)
- Authentication-results: sourceware.org; auth=none
- References: <CA+=Sn1m-pMkB1Vvoi3s_N0DSwLioB3T90778oSDQNOYME83txA@mail.gmail.com> <alpine.DEB.2.20.1706250909190.2070@stedding.saclay.inria.fr> <CA+=Sn1nj_TNWUCGn9V_hqF2gcPj=WbzxN565FOA02O6qFg8_cA@mail.gmail.com> <CA+=Sn1mdyqOy+6UuuTXJH6UvtdNT2AS_VLWCHU_kK3kXg+apBQ@mail.gmail.com> <VI1PR0801MB203165124FCDF1D4F11203F3FFDC0@VI1PR0801MB2031.eurprd08.prod.outlook.com>
On June 27, 2017 4:52:28 PM GMT+02:00, Tamar Christina <Tamar.Christina@arm.com> wrote:
>> >> +(for cmp (gt ge lt le)
>> >> + outp (convert convert negate negate)
>> >> + outn (negate negate convert convert)
>> >> + /* Transform (X > 0.0 ? 1.0 : -1.0) into copysign(1, X). */
>> >> + /* Transform (X >= 0.0 ? 1.0 : -1.0) into copysign(1, X). */
>> >> + /* Transform (X < 0.0 ? 1.0 : -1.0) into copysign(1,-X). */
>> >> + /* Transform (X <= 0.0 ? 1.0 : -1.0) into copysign(1,-X). */
>> >> +(simplify
>> >> + (cond (cmp @0 real_zerop) real_onep real_minus_onep)
>> >> + (if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type)
>> >> + && types_match (type, TREE_TYPE (@0)))
>> >> + (switch
>> >> + (if (types_match (type, float_type_node))
>> >> + (BUILT_IN_COPYSIGNF { build_one_cst (type); } (outp @0)))
>> >> + (if (types_match (type, double_type_node))
>> >> + (BUILT_IN_COPYSIGN { build_one_cst (type); } (outp @0)))
>> >> + (if (types_match (type, long_double_type_node))
>> >> + (BUILT_IN_COPYSIGNL { build_one_cst (type); } (outp @0))))))
>> >>
>
>Hi,
>
>Out of curiosity is there any reason why this transformation can't be
>more general?
>
>e.g. Transform (X > 0.0 ? CST : -CST) into copysign(CST, X).
That's also possible, yes.
>we would at the very least avoid a csel or a branch then.
>
>Regards,
>Tamar
- References:
- [PATCH] Fold (a > 0 ? 1.0 : -1.0) into copysign (1.0, a) and a * copysign (1.0, a) into abs(a)
- Re: [PATCH] Fold (a > 0 ? 1.0 : -1.0) into copysign (1.0, a) and a * copysign (1.0, a) into abs(a)
- Re: [PATCH] Fold (a > 0 ? 1.0 : -1.0) into copysign (1.0, a) and a * copysign (1.0, a) into abs(a)
- Re: [PATCH] Fold (a > 0 ? 1.0 : -1.0) into copysign (1.0, a) and a * copysign (1.0, a) into abs(a)
- RE: [PATCH] Fold (a > 0 ? 1.0 : -1.0) into copysign (1.0, a) and a * copysign (1.0, a) into abs(a)