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: Uros Bizjak <ubizjak at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Andrew Pinski <pinskia at gmail dot com>, Richard Biener <richard dot guenther at gmail dot com>, Tamar Christina <Tamar dot Christina at arm dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Wed, 28 Jun 2017 09:57:16 +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> <66B5847A-AD5F-48F2-BB42-BAF25BA3605F@gmail.com> <CA+=Sn1mYDF+OXehnfSONoWCQw=RA9xaOVbxkcWBfV5MG-AfVsg@mail.gmail.com> <20170628073745.GW2123@tucnak>
On Wed, Jun 28, 2017 at 9:37 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Jun 27, 2017 at 10:52:47AM -0700, Andrew Pinski wrote:
>> On Tue, Jun 27, 2017 at 7:56 AM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>> > 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))))))
>
> The patch regressed the gcc.target/i386/cmov7.c testcase.
> From the description in the testcase it was testing the combiner, so I've
> transformed it into something that also tests the combiner the same way,
> ok for trunk? That said, for copysign if we match it we don't emit a fcmov
> while it might be a good idea.
>
> 2017-06-28 Jakub Jelinek <jakub@redhat.com>
>
> * gcc.target/i386/cmov7.c (sgn): Renamed to ...
> (foo): ... this. Change constants such that it isn't matched
> as __builtin_copysign, yet tests the combiner the same.
OK.
Thanks,
Uros.
> --- gcc/testsuite/gcc.target/i386/cmov7.c.jj 2016-05-22 12:20:23.000000000 +0200
> +++ gcc/testsuite/gcc.target/i386/cmov7.c 2017-06-28 09:20:24.000000000 +0200
> @@ -10,7 +10,7 @@
> (set (reg:DF) (float_extend:DF (mem:SF (symbol_ref...)))). */
>
> double
> -sgn (double __x)
> +foo (double __x)
> {
> - return __x >= 0.0 ? 1.0 : -1.0;
> + return __x >= 1.0 ? 0.0 : -1.0;
> }
>
>
> Jakub
- 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)
- 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)