aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2015-04-14 10:49:16 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2015-04-14 08:49:16 +0000
commitcfdc4f334db1ad1f44eb81bb827d6c39074c522d (patch)
tree303b6ee944e7bb83cf7f5c1426ae476c4d0d8585 /gcc
parent55d2ee5737e56cec20646bc378cb7e7ad2ecb02d (diff)
downloadgcc-cfdc4f334db1ad1f44eb81bb827d6c39074c522d.zip
gcc-cfdc4f334db1ad1f44eb81bb827d6c39074c522d.tar.gz
gcc-cfdc4f334db1ad1f44eb81bb827d6c39074c522d.tar.bz2
re PR other/63387 (Optimize pairs of isnan() calls into a single isunordered())
2015-04-14 Marc Glisse <marc.glisse@inria.fr> PR tree-optimization/63387 gcc/ * match.pd ((x unord x) | (y unord y) -> (x unord y), (x unord x) | (x unord y) -> (x unord y)): New simplifications. gcc/testsuite/ * gcc.dg/pr63387.c: New testcase. From-SVN: r222077
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/match.pd9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr63387.c26
4 files changed, 46 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b1b06b3..f44fd64 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-14 Marc Glisse <marc.glisse@inria.fr>
+
+ PR tree-optimization/63387
+ * match.pd ((x unord x) | (y unord y) -> (x unord y),
+ (x unord x) | (x unord y) -> (x unord y)): New simplifications.
+
2015-04-14 Uros Bizjak <ubizjak@gmail.com>
* config/i386/predicates.md (any_QIreg_operand): Rename from
diff --git a/gcc/match.pd b/gcc/match.pd
index d438179..fc374de 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -932,6 +932,15 @@ along with GCC; see the file COPYING3. If not see
(if (ic == ncmp)
(ncmp @0 @1)))))
+/* Unordered tests if either argument is a NaN. */
+(simplify
+ (bit_ior (unordered @0 @0) (unordered @1 @1))
+ (if ((GIMPLE && types_compatible_p (TREE_TYPE (@0), TREE_TYPE (@1)))
+ || (GENERIC && TREE_TYPE (@0) == TREE_TYPE (@1)))
+ (unordered @0 @1)))
+(simplify
+ (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
+ @2)
/* Simplification of math builtins. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 18ce31c..aec780b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-14 Marc Glisse <marc.glisse@inria.fr>
+
+ PR tree-optimization/63387
+ * gcc.dg/pr63387.c: New testcase.
+
2015-04-12 Jan Hubicka <hubicka@ucw.cz>
* g++.dg/tree-ssa/nonzero-3.C: New testcase.
diff --git a/gcc/testsuite/gcc.dg/pr63387.c b/gcc/testsuite/gcc.dg/pr63387.c
new file mode 100644
index 0000000..1814fe0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr63387.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\]* unord aaa" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* unord bbb" "optimized" } } */
+/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* unord bbb" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "ccc\[^\n\r\]* unord ddd" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */