I have mistakenly assumed that switch lowering cannot encounter a switch
with zero clusters. This patch removes the relevant assert and instead
gives up bit-test lowering when this happens.
PR tree-optimization/120080
gcc/ChangeLog:
* tree-switch-conversion.cc (bit_test_cluster::find_bit_tests):
Replace assert with return.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr120080.c: New test.
Signed-off-by: Filip Kastl <fkastl@suse.cz>
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fgimple -O2" } */
+
+void __GIMPLE (ssa,startwith("switchlower1"))
+foo (int b)
+{
+ __BB(2):
+ switch (b) {default: L9; case 0: L5; case 5: L5; case 101: L5; }
+
+ __BB(3):
+L9:
+ switch (b) {default: L7; case 5: L6; case 101: L6; }
+
+ __BB(4):
+L6:
+ __builtin_unreachable ();
+
+ __BB(5):
+L7:
+ __builtin_trap ();
+
+ __BB(6):
+L5:
+ return;
+
+}
end up with as few clusters as possible. */
unsigned l = clusters.length ();
- auto_vec<min_cluster_item> min;
- min.reserve (l + 1);
- gcc_checking_assert (l > 0);
+ if (l == 0)
+ return clusters.copy ();
gcc_checking_assert (l <= INT_MAX);
+ auto_vec<min_cluster_item> min;
+ min.reserve (l + 1);
+
int bits_in_word = GET_MODE_BITSIZE (word_mode);
/* First phase: Compute the minimum number of clusters for each prefix of the