This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] make find_taken_edge handle case with just default
- From: Peter Bergner <bergner at vnet dot ibm dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 29 Jun 2017 08:55:13 -0500
- Subject: Re: [PATCH] make find_taken_edge handle case with just default
- Authentication-results: sourceware.org; auth=none
- References: <alpine.LSU.2.20.1706291100160.23185@zhemvz.fhfr.qr>
On 6/29/17 4:03 AM, Richard Biener wrote:
>
> This refactors things a bit to make CFG cleanup handle switches with
> just a default label. If we make sure to cleanup the CFG after
> group_case_labels removes cases with just __builtin_unreachable ()
> inside then this fixes the ICE seen in PR81994 as well.
>
> I wonder if find_taken_edge should generally handle successors
> with __builtin_unreachable () -- OTOH that would get rid of those
> too early I guess.
Should we offer an early out of group_case_labels_stmt() for the
fairly common case of new_size == old_size? There's no reason to
execute the compress labels loop if we didn't combine any of the
labels.
Peter
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 249783)
+++ gcc/tree-cfg.c (working copy)
@@ -1747,6 +1747,11 @@ group_case_labels_stmt (gswitch *stmt)
}
}
+ gcc_assert (new_size <= old_size);
+
+ if (new_size == old_size)
+ return false;
+
/* Compress the case labels in the label vector, and adjust the
length of the vector. */
for (i = 0, j = 0; i < new_size; i++)
@@ -1757,9 +1762,8 @@ group_case_labels_stmt (gswitch *stmt)
gimple_switch_label (stmt, j++));
}
- gcc_assert (new_size <= old_size);
gimple_switch_set_num_labels (stmt, new_size);
- return new_size < old_size;
+ return true;
}
/* Look for blocks ending in a multiway branch (a GIMPLE_SWITCH),