re PR tree-optimization/89570 (ICE in prepare_cmp_insn, at optabs.c:4001)
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Mar 2019 08:44:21 +0000 (09:44 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Mar 2019 08:44:21 +0000 (09:44 +0100)
PR tree-optimization/89570
* match.pd (vec_cond into cond_op simplification): Guard with
vectorized_internal_fn_supported_p test and #if GIMPLE.

* gcc.dg/pr89570.c: New test.

From-SVN: r269385

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr89570.c [new file with mode: 0644]

index 22ce3646ee1bb547548dd522ffc95469eacef9dd..54c736b340be07cd070256abdcdc5001df1d4636 100644 (file)
@@ -1,5 +1,9 @@
 2019-03-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/89570
+       * match.pd (vec_cond into cond_op simplification): Guard with
+       vectorized_internal_fn_supported_p test and #if GIMPLE.
+
        PR tree-optimization/89566
        * gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call):
        Set info.fncode to BUILT_IN_NONE if gimple_call_builtin_p failed.
index c9af2e59441c4fe19e88d94c9d138ae35dfe673f..8bf653549de2d0e4c9e9b59edd82b9f708df9dcf 100644 (file)
@@ -5177,17 +5177,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    if the target can do it in one go.  This makes the operation conditional
    on c, so could drop potentially-trapping arithmetic, but that's a valid
    simplification if the result of the operation isn't needed.  */
+#if GIMPLE
 (for uncond_op (UNCOND_BINARY)
      cond_op (COND_BINARY)
  (simplify
   (vec_cond @0 (view_convert? (uncond_op@4 @1 @2)) @3)
-  (with { tree op_type = TREE_TYPE (@4); }
-   (if (element_precision (type) == element_precision (op_type))
+  (with { tree op_type = TREE_TYPE (@4); 
+         internal_fn cond_fn = get_conditional_internal_fn (uncond_op); }
+   (if (cond_fn != IFN_LAST
+       && vectorized_internal_fn_supported_p (cond_fn, op_type)
+       && element_precision (type) == element_precision (op_type))
     (view_convert (cond_op @0 @1 @2 (view_convert:op_type @3))))))
  (simplify
   (vec_cond @0 @1 (view_convert? (uncond_op@4 @2 @3)))
-  (with { tree op_type = TREE_TYPE (@4); }
-   (if (element_precision (type) == element_precision (op_type))
+  (with { tree op_type = TREE_TYPE (@4);
+         internal_fn cond_fn = get_conditional_internal_fn (uncond_op); }
+   (if (cond_fn != IFN_LAST
+       && vectorized_internal_fn_supported_p (cond_fn, op_type)
+       && element_precision (type) == element_precision (op_type))
     (view_convert (cond_op (bit_not @0) @2 @3 (view_convert:op_type @1)))))))
 
 /* Same for ternary operations.  */
@@ -5195,15 +5202,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
      cond_op (COND_TERNARY)
  (simplify
   (vec_cond @0 (view_convert? (uncond_op@5 @1 @2 @3)) @4)
-  (with { tree op_type = TREE_TYPE (@5); }
-   (if (element_precision (type) == element_precision (op_type))
+  (with { tree op_type = TREE_TYPE (@5);
+         internal_fn cond_fn
+           = get_conditional_internal_fn (as_internal_fn (uncond_op)); }
+   (if (cond_fn != IFN_LAST
+       && vectorized_internal_fn_supported_p (cond_fn, op_type)
+       && element_precision (type) == element_precision (op_type))
     (view_convert (cond_op @0 @1 @2 @3 (view_convert:op_type @4))))))
  (simplify
   (vec_cond @0 @1 (view_convert? (uncond_op@5 @2 @3 @4)))
-  (with { tree op_type = TREE_TYPE (@5); }
-   (if (element_precision (type) == element_precision (op_type))
+  (with { tree op_type = TREE_TYPE (@5);
+         internal_fn cond_fn
+           = get_conditional_internal_fn (as_internal_fn (uncond_op)); }
+   (if (cond_fn != IFN_LAST
+       && vectorized_internal_fn_supported_p (cond_fn, op_type)
+       && element_precision (type) == element_precision (op_type))
     (view_convert (cond_op (bit_not @0) @2 @3 @4
                  (view_convert:op_type @1)))))))
+#endif
 
 /* Detect cases in which a VEC_COND_EXPR effectively replaces the
    "else" value of an IFN_COND_*.  */
index a5e25c3284dad78123a827ee8e810072fb7cd87a..f9d770c96f15a811adac1e981078ed2add2984d8 100644 (file)
@@ -1,5 +1,8 @@
 2019-03-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/89570
+       * gcc.dg/pr89570.c: New test.
+
        PR tree-optimization/89566
        * c-c++-common/pr89566.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr89570.c b/gcc/testsuite/gcc.dg/pr89570.c
new file mode 100644 (file)
index 0000000..cae5a25
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR tree-optimization/89570 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftree-vectorize -fno-trapping-math -fno-tree-dce -fno-tree-dominator-opts" } */
+/* { dg-additional-options "-mvsx" { target powerpc_vsx_ok } } */
+
+void
+foo (double *x, double *y, double *z)
+{
+  int i;
+  for (i = 0; i < 7; i += 2)
+    {
+      x[i] = y[i] ? z[i] / 2.0 : z[i];
+      x[i + 1] = y[i + 1] ? z[i + 1] / 2.0 : z[i + 1];
+    }
+}