aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2015-05-22 23:05:26 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2015-05-22 21:05:26 +0000
commit257b01ba3e72667536024aab8f2d3f506b2117e3 (patch)
tree0661107ebb924daf8be432841222366fbbb22e80
parentb8f75b8cde8c632738e447f5493aea7b30be8e32 (diff)
downloadgcc-257b01ba3e72667536024aab8f2d3f506b2117e3.zip
gcc-257b01ba3e72667536024aab8f2d3f506b2117e3.tar.gz
gcc-257b01ba3e72667536024aab8f2d3f506b2117e3.tar.bz2
re PR other/63387 (Optimize pairs of isnan() calls into a single isunordered())
2015-05-22 Marc Glisse <marc.glisse@inria.fr> 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) <ABS_EXPR>: Handle vectors like scalars. gcc/testsuite/ * gcc.dg/pr63387-2.c: New testcase. From-SVN: r223591
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/match.pd10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr63387-2.c26
5 files changed, 49 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index da46583..3d38d45 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
2015-05-22 Marc Glisse <marc.glisse@inria.fr>
+ 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) <ABS_EXPR>: Handle
+ vectors like scalars.
+
+2015-05-22 Marc Glisse <marc.glisse@inria.fr>
+
* 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 1476ee0..c38a633 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> = 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 33419ebd..3ac3645 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 63ebd45..fe5d962 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2015-05-22 Marc Glisse <marc.glisse@inria.fr>
+ PR tree-optimization/63387
+ * gcc.dg/pr63387-2.c: New testcase.
+
+2015-05-22 Marc Glisse <marc.glisse@inria.fr>
+
* gcc.dg/simd-1.c: Update to the new message.
2015-05-22 Marc Glisse <marc.glisse@inria.fr>
diff --git a/gcc/testsuite/gcc.dg/pr63387-2.c b/gcc/testsuite/gcc.dg/pr63387-2.c
new file mode 100644
index 0000000..872195a
--- /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" } } */