re PR tree-optimization/81428 (ICE: in build_one_cst, at tree.c:2079 with -O2. Fixed...
authorJakub Jelinek <jakub@redhat.com>
Mon, 17 Jul 2017 10:20:41 +0000 (12:20 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 17 Jul 2017 10:20:41 +0000 (12:20 +0200)
PR tree-optimization/81428
* match.pd (X / X -> one): Don't optimize _Fract divisions, as 1
can't be built for those types.

* gcc.dg/fixed-point/pr81428.c: New test.

From-SVN: r250265

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/fixed-point/pr81428.c [new file with mode: 0644]

index db3540155efe1504a23ba22e6c996304ee97303c..0c279095cf412d85056b09576e5b824d75ff3af4 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/81428
+       * match.pd (X / X -> one): Don't optimize _Fract divisions, as 1
+       can't be built for those types.
+
 2017-07-17  Georg-Johann Lay  <avr@gjlay.de>
 
        Remove stuff dead since r239246.
index 4c64b21b46394c72fcb4a6d6719791c4696bf09d..979085aba5ae67faff3d6613275ab271632f3de5 100644 (file)
@@ -243,8 +243,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  /* X / X is one.  */
  (simplify
   (div @0 @0)
-  /* But not for 0 / 0 so that we can get the proper warnings and errors.  */
-  (if (!integer_zerop (@0))
+  /* But not for 0 / 0 so that we can get the proper warnings and errors.
+     And not for _Fract types where we can't build 1.  */
+  (if (!integer_zerop (@0) && !ALL_FRACT_MODE_P (TYPE_MODE (type)))
    { build_one_cst (type); }))
  /* X / abs (X) is X < 0 ? -1 : 1.  */ 
  (simplify
index 141d035cf6dbcc30ab12b732f66106cf64fa8917..4924b481427695c70524814dcb5134a006aae10f 100644 (file)
@@ -1,5 +1,8 @@
 2017-07-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/81428
+       * gcc.dg/fixed-point/pr81428.c: New test.
+
        PR tree-optimization/81365
        * g++.dg/torture/pr81365.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/fixed-point/pr81428.c b/gcc/testsuite/gcc.dg/fixed-point/pr81428.c
new file mode 100644 (file)
index 0000000..98f4b23
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR tree-optimization/81428 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo (long _Fract *a, long _Fract *b)
+{
+  *b = *a / *a;
+}