From 4119b2eb4417054c98e0960a5dbe91284bdacdbf Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Mon, 13 Nov 2017 19:06:49 +0000 Subject: [PATCH] match.pd: Convert fminf... [gcc] 2017-11-13 Michael Meissner * match.pd: Convert fminf, fminfx, fmax, and fmaxx into the min/max operations for _Float and _FloatX types. [gcc/testsuite] 2017-11-13 Michael Meissner * gcc.target/powerpc/float128-minmax.c: New test. From-SVN: r254702 --- gcc/ChangeLog | 5 +++++ gcc/match.pd | 14 ++++++++++---- gcc/testsuite/ChangeLog | 4 ++++ .../gcc.target/powerpc/float128-minmax.c | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/float128-minmax.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 543a8e1a739..fee8dca455e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-11-13 Michael Meissner + + * match.pd: Convert fminf, fminfx, fmax, and fmaxx + into the min/max operations for _Float and _FloatX types. + 2017-11-13 Eric Botcazou PR lto/81351 diff --git a/gcc/match.pd b/gcc/match.pd index 4d56847d688..2557f08ad35 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1803,7 +1803,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* Simplifications of MIN_EXPR, MAX_EXPR, fmin() and fmax(). */ -(for minmax (min max FMIN FMAX) +(for minmax (min max FMIN FMIN_FN FMAX FMAX_FN) (simplify (minmax @0 @0) @0)) @@ -1881,7 +1881,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type)) (minmax @1 (convert @2))))) -(for minmax (FMIN FMAX) +(for minmax (FMIN FMIN_FN FMAX FMAX_FN) /* If either argument is NaN, return the other one. Avoid the transformation if we get (and honor) a signalling NaN. */ (simplify @@ -1898,12 +1898,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (FMIN @0 @1) (min @0 @1)) + (simplify + (FMIN_FN @0 @1) + (min @0 @1)) (simplify (FMAX @0 @1) + (max @0 @1)) + (simplify + (FMAX_FN @0 @1) (max @0 @1))) /* min (-A, -B) -> -max (A, B) */ -(for minmax (min max FMIN FMAX) - maxmin (max min FMAX FMIN) +(for minmax (min max FMIN FMIN_FN FMAX FMAX_FN) + maxmin (max min FMAX FMAX_FN FMIN FMAX_FN) (simplify (minmax (negate:s@2 @0) (negate:s@3 @1)) (if (FLOAT_TYPE_P (TREE_TYPE (@0)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 85e71b3e408..413d7e51e81 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-11-13 Michael Meissner + + * gcc.target/powerpc/float128-minmax.c: New test. + 2017-11-13 Christophe Lyon * gcc.target/arm/pr67989.C: Add -Wno-return-type to diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax.c b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c new file mode 100644 index 00000000000..f8b025d66fe --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-mpower9-vector -O2 -ffast-math" } */ + +#ifndef TYPE +#define TYPE _Float128 +#endif + +/* Test that the fminf128/fmaxf128 functions generate if/then/else and not a + call. */ +TYPE f128_min (TYPE a, TYPE b) { return __builtin_fminf128 (a, b); } +TYPE f128_max (TYPE a, TYPE b) { return __builtin_fmaxf128 (a, b); } + +/* { dg-final { scan-assembler {\mxscmpuqp\M} } } */ +/* { dg-final { scan-assembler-not {\mbl\M} } } */ -- 2.30.2