re PR middle-end/82319 (ICE in generic_simplify_148, at generic-match.c:6436)
authorYury Gribov <tetra2005@gmail.com>
Fri, 29 Sep 2017 19:40:16 +0000 (19:40 +0000)
committerYury Gribov <ygribov@gcc.gnu.org>
Fri, 29 Sep 2017 19:40:16 +0000 (19:40 +0000)
2017-09-29  Yury Gribov  <tetra2005@gmail.com>

PR middle-end/82319
gcc/
* match.pd: Fix handling of NaNs in pattern.

gcc/testsuite/
* c-c++/common/pr57371-4.c: Test NaN comparisons.

From-SVN: r253307

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr57371-4.c

index 1932390dd0aaa714b91b5a4aad25bdeab298fb82..2063108fdfb7ca394855314d6509ba1f47b0d75e 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-29  Yury Gribov  <tetra2005@gmail.com>
+
+       PR middle-end/82319
+       * match.pd: Fix handling of NaNs in pattern.
+
 2017-09-29  Jeff Law  <law@redhat.com>
 
        * sbitmap.c (bitmap_bit_in_range_p): New function.
index 43ab226a705ad17bf04c37cc9c9ee5578b2341a1..1136a598abb139673ff54bd57e5bfd7fbe335ac7 100644 (file)
@@ -2961,7 +2961,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
         else
           real_trunc (&icst, fmt, cst);
 
-        bool cst_int_p = real_identical (&icst, cst);
+        bool cst_int_p = !real_isnan (cst) && real_identical (&icst, cst);
 
         bool overflow_p = false;
         wide_int icst_val
index 0cf96a9e8ef8dfcc0ab21f5ba3b4a5114ce28036..8cb533bd58b50e97497b8a2db23cf34439c14c4b 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-29  Yury Gribov  <tetra2005@gmail.com>
+
+       PR middle-end/82319
+       * c-c++/common/pr57371-4.c: Test NaN comparisons.
+
 2017-09-29  Eric Botcazou  <ebotcazou@adacore.com>
 
        * g++.dg/other/dump-ada-spec-10.C: New test.
index 6265f520f9300aef5a4c1e79e79f3a094ceaf500..f43f7c22419a56661ebcb284fa648f478be1833f 100644 (file)
@@ -69,4 +69,16 @@ void nonfinite(unsigned short x) {
     nonfinite_10 = (float) x != SNAN;
     /* { dg-final { scan-tree-dump "nonfinite_10 = \\(float\\)" "original" } } */
   }
+
+  {
+    volatile int nonfinite_11;
+    nonfinite_11 = (float) x == QNAN;
+    /* { dg-final { scan-tree-dump "nonfinite_11 = 0" "original" } } */
+  }
+
+  {
+    volatile int nonfinite_12;
+    nonfinite_12 = (float) x != QNAN;
+    /* { dg-final { scan-tree-dump "nonfinite_12 = 1" "original" } } */
+  }
 }