On June 15, 2018 8:59:11 PM GMT+02:00, Jakub Jelinek <ja...@redhat.com> wrote:
>Hi!
>
>We allow only equality/non-equality comparisons of complex numbers, so
>introducing less than or greater or equal than comparison for them from
>non-equality ones + division is a bad idea; e.g. the expansion will not
>handle those.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
>trunk/8.2?

OK. 

Richard. 

>2018-06-15  Jakub Jelinek  <ja...@redhat.com>
>
>       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.
>
>--- gcc/match.pd.jj    2018-06-14 21:07:15.785350884 +0200
>+++ gcc/match.pd       2018-06-15 08:14:56.134977947 +0200
>@@ -1462,14 +1462,15 @@ (define_operator_list COND_BINARY
>    (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))))
> 
>--- gcc/testsuite/gcc.c-torture/compile/pr86123.c.jj   2018-06-15
>08:27:24.851654403 +0200
>+++ gcc/testsuite/gcc.c-torture/compile/pr86123.c      2018-06-15
>08:27:11.632645612 +0200
>@@ -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;
>+}
>
>       Jakub

Reply via email to