On Wed, Aug 7, 2024 at 9:33 PM Andi Kleen <a...@firstfloor.org> wrote: > > > > + /* Create chain of switch tests for each case. */ > > > + tree switch_cond = NULL_TREE; > > > + tree index = gimple_switch_index (sw); > > > + for (unsigned i = 1; i < gimple_switch_num_labels (sw); i++) > > > + { > > > + tree label = gimple_switch_label (sw, i); > > > + tree case_cond; > > > + /* This currently cannot happen because tree-cfg lowers > > > range > > > + switches with a single destination to COND. */ > > > > But it should also lower non-range switches with a single destination ...? > > See convert_single_case_switch. You say > > > > switch (i) > > { > > case 1: > > case 5 ... 7: > > return 42; > > default: > > return 0; > > } > > > > doesn't hit here with a CASE_HIGH for the 5 ... 7 CASE_LABEL? > > Yes it can actually happen. I'll correct the comment/description > and add a test case. > > But your comment made me realize there is a major bug. > > if_convertible_switch_p also needs to check that that the labels don't fall > through, so the the flow graph is diamond shape. Need some easy way to > verify that.
Do we verify this for if()s? That is, if (i) { ... goto fallthru; } else { fallthru: ... } For ifs we seem to add the predicate to both edges even in the degenerate case. > > -Andi