Hi!

The following testcase ICEs, because ifcombine_ifandif attempts to set
GIMPLE_COND condition to a condition that might trap (which is allowed
only in COND_EXPR/VEC_COND_EXPR).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2019-10-17  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/92115
        * tree-ssa-ifcombine.c (ifcombine_ifandif): Force condition into
        temporary if it could trap.

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

--- gcc/tree-ssa-ifcombine.c.jj 2019-09-20 12:25:42.232479343 +0200
+++ gcc/tree-ssa-ifcombine.c    2019-10-16 10:05:06.826174814 +0200
@@ -599,6 +599,12 @@ ifcombine_ifandif (basic_block inner_con
       t = canonicalize_cond_expr_cond (t);
       if (!t)
        return false;
+      if (!is_gimple_condexpr_for_cond (t))
+       {
+         gsi = gsi_for_stmt (inner_cond);
+         t = force_gimple_operand_gsi_1 (&gsi, t, is_gimple_condexpr_for_cond,
+                                         NULL, true, GSI_SAME_STMT);
+       }
       gimple_cond_set_condition_from_tree (inner_cond, t);
       update_stmt (inner_cond);
 
--- gcc/testsuite/gcc.dg/pr92115.c.jj   2019-10-16 10:07:35.923924633 +0200
+++ gcc/testsuite/gcc.dg/pr92115.c      2019-10-16 10:06:56.831514691 +0200
@@ -0,0 +1,10 @@
+/* PR tree-optimization/92115 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fexceptions -ffinite-math-only -fnon-call-exceptions 
-fsignaling-nans -fno-signed-zeros" } */
+
+void
+foo (double x)
+{
+  if (x == 0.0 && !__builtin_signbit (x))
+    __builtin_abort ();
+}

        Jakub

Reply via email to