re PR middle-end/86123 (ICE in prepare_cmp_insn, at optabs.c:3967)
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Jun 2018 19:30:58 +0000 (21:30 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 15 Jun 2018 19:30:58 +0000 (21:30 +0200)
PR middle-end/86123
* match.pd ((X / Y) == 0 -> X < Y): Don't transform complex divisions.
Fix up comment formatting.

* gcc.c-torture/compile/pr86123.c: New test.

From-SVN: r261647

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr86123.c [new file with mode: 0644]

index c91c81effcc1c240a8728e6f5745a75628fee090..9c7c574c762756bfa91c966b78be52e39b96bf5e 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/86123
+       * match.pd ((X / Y) == 0 -> X < Y): Don't transform complex divisions.
+       Fix up comment formatting.
+
 2018-06-15  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * typed-splay-tree.h (typed_splay_tree::remove): New function.
index f70a88c362ef7d00450995cff893526d2ed59c8f..7e22771ec7c01e644cf20c83de23914fca96df33 100644 (file)
@@ -1462,14 +1462,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (op @1 { build_zero_cst (TREE_TYPE (@1)); }))))
 
 /* Transform:
- * (X / Y) == 0 -> X < Y if X, Y are unsigned.
- * (X / Y) != 0 -> X >= Y, if X, Y are unsigned.
- */
+   (X / Y) == 0 -> X < Y if X, Y are unsigned.
+   (X / Y) != 0 -> X >= Y, if X, Y are unsigned.  */
 (for cmp (eq ne)
      ocmp (lt ge)
  (simplify
   (cmp (trunc_div @0 @1) integer_zerop)
   (if (TYPE_UNSIGNED (TREE_TYPE (@0))
+       /* Complex ==/!= is allowed, but not </>=.  */
+       && TREE_CODE (TREE_TYPE (@0)) != COMPLEX_TYPE
        && (VECTOR_TYPE_P (type) || !VECTOR_TYPE_P (TREE_TYPE (@0))))
    (ocmp @0 @1))))
 
index 72b8615a612b3ae3f0cdef34039c2a24a7614d98..045c4cd68493e82ac18b2d3d29210cb78776c94b 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/86123
+       * gcc.c-torture/compile/pr86123.c: New test.
+
 2018-06-15  Tom de Vries  <tdevries@suse.de>
 
        * gcc.dg-selftests/dg-final.exp: Force sequential execution.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr86123.c b/gcc/testsuite/gcc.c-torture/compile/pr86123.c
new file mode 100644 (file)
index 0000000..707e6dc
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR middle-end/86123 */
+
+int
+foo (_Complex unsigned x, _Complex unsigned y)
+{
+  _Complex unsigned t1 = x / y;
+  int t2 = (t1 != 0);
+  return t2;
+}
+
+int
+bar (_Complex unsigned x, _Complex unsigned y)
+{
+  _Complex unsigned t1 = x / y;
+  int t2 = (t1 == 0);
+  return t2;
+}