From 257b01ba3e72667536024aab8f2d3f506b2117e3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 22 May 2015 23:05:26 +0200 Subject: [PATCH] re PR other/63387 (Optimize pairs of isnan() calls into a single isunordered()) 2015-05-22 Marc Glisse PR tree-optimization/63387 gcc/ * match.pd ((X /[ex] A) * A -> X): Remove unnecessary condition. ((x ord x) & (y ord y) -> (x ord y), (x ord x) & (x ord y) -> (x ord y)): New simplifications. * fold-const.c (tree_unary_nonnegative_warnv_p) : Handle vectors like scalars. gcc/testsuite/ * gcc.dg/pr63387-2.c: New testcase. From-SVN: r223591 --- gcc/ChangeLog | 9 +++++++++ gcc/fold-const.c | 2 +- gcc/match.pd | 10 ++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr63387-2.c | 26 ++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr63387-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da465838256..3d38d45d484 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2015-05-22 Marc Glisse + PR tree-optimization/63387 + * match.pd ((X /[ex] A) * A -> X): Remove unnecessary condition. + ((x ord x) & (y ord y) -> (x ord y), + (x ord x) & (x ord y) -> (x ord y)): New simplifications. + * fold-const.c (tree_unary_nonnegative_warnv_p) : Handle + vectors like scalars. + +2015-05-22 Marc Glisse + * convert.c (convert_to_integer, convert_to_vector): Include the types in the error message. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 1476ee0b1ed..c38a63336d3 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -14688,7 +14688,7 @@ tree_unary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0, case ABS_EXPR: /* We can't return 1 if flag_wrapv is set because ABS_EXPR = INT_MIN. */ - if (!INTEGRAL_TYPE_P (type)) + if (!ANY_INTEGRAL_TYPE_P (type)) return true; if (TYPE_OVERFLOW_UNDEFINED (type)) { diff --git a/gcc/match.pd b/gcc/match.pd index 33419ebdcb6..3ac36455278 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -818,8 +818,7 @@ along with GCC; see the file COPYING3. If not see (simplify (mult (convert? (exact_div @0 @1)) @1) /* Look through a sign-changing conversion. */ - (if (TYPE_PRECISION (TREE_TYPE (@0)) == TYPE_PRECISION (type)) - (convert @0))) + (convert @0)) /* Canonicalization of binary operations. */ @@ -971,8 +970,15 @@ along with GCC; see the file COPYING3. If not see (if (types_match (@0, @1)) (unordered @0 @1))) (simplify + (bit_and (ordered @0 @0) (ordered @1 @1)) + (if (types_match (@0, @1)) + (ordered @0 @1))) +(simplify (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1)) @2) +(simplify + (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1)) + @2) /* Simplification of math builtins. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 63ebd45dc98..fe5d962c36c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2015-05-22 Marc Glisse + PR tree-optimization/63387 + * gcc.dg/pr63387-2.c: New testcase. + +2015-05-22 Marc Glisse + * gcc.dg/simd-1.c: Update to the new message. 2015-05-22 Marc Glisse diff --git a/gcc/testsuite/gcc.dg/pr63387-2.c b/gcc/testsuite/gcc.dg/pr63387-2.c new file mode 100644 index 00000000000..872195a1787 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr63387-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +int f(double aaa, double bbb){ + int xa = !__builtin_isunordered(aaa, aaa); + int xb = !__builtin_isunordered(bbb, bbb); + return xa & xb; +} + +int g(double aaa, double bbb){ + int xa = !__builtin_isunordered(aaa, bbb); + int xb = !__builtin_isunordered(bbb, bbb); + return xa & xb; +} + +int h(double ccc, float ddd){ + int xc = !__builtin_isunordered(ccc, ccc); + int xd = !__builtin_isunordered(ddd, ddd); + return xc & xd; +} + +/* { dg-final { scan-tree-dump-not "aaa\[^\n\r\]* ord aaa" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* ord bbb" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* ord bbb" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "ccc\[^\n\r\]* ord ddd" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ -- 2.11.4.GIT