https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68870

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The right (TM) fix:

Index: gcc/tree-cfgcleanup.c
===================================================================
--- gcc/tree-cfgcleanup.c       (revision 231617)
+++ gcc/tree-cfgcleanup.c       (working copy)
@@ -95,15 +95,9 @@ cleanup_control_expr_graph (basic_block
       switch (gimple_code (stmt))
        {
        case GIMPLE_COND:
-         {
-           code_helper rcode;
-           tree ops[3] = {};
-           if (gimple_simplify (stmt, &rcode, ops, NULL, no_follow_ssa_edges,
-                                no_follow_ssa_edges)
-               && rcode == INTEGER_CST)
-             val = ops[0];
-           break;
-         }
+         val = const_binop (gimple_cond_code (stmt), boolean_type_node,
+                            gimple_cond_lhs (stmt), gimple_cond_rhs (stmt));
+         break;

        case GIMPLE_SWITCH:
          val = gimple_switch_index (as_a <gswitch *> (stmt));

and the following shows the regressions:

Index: gcc/tree-cfgcleanup.c
===================================================================
--- gcc/tree-cfgcleanup.c       (revision 231617)
+++ gcc/tree-cfgcleanup.c       (working copy)
@@ -95,15 +95,18 @@ cleanup_control_expr_graph (basic_block
       switch (gimple_code (stmt))
        {
        case GIMPLE_COND:
-         {
-           code_helper rcode;
-           tree ops[3] = {};
-           if (gimple_simplify (stmt, &rcode, ops, NULL, no_follow_ssa_edges,
-                                no_follow_ssa_edges)
-               && rcode == INTEGER_CST)
-             val = ops[0];
-           break;
-         }
+         val = const_binop (gimple_cond_code (stmt), boolean_type_node,
+                            gimple_cond_lhs (stmt), gimple_cond_rhs (stmt));
+         if (!val)
+           {
+             code_helper rcode;
+             tree ops[3] = {};
+             if (gimple_simplify (stmt, &rcode, ops, NULL,
no_follow_ssa_edges,
+                                  no_follow_ssa_edges)
+                 && rcode == INTEGER_CST)
+               gcc_unreachable ();
+           }
+         break;

        case GIMPLE_SWITCH:
          val = gimple_switch_index (as_a <gswitch *> (stmt));

Reply via email to