https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80460
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Actually, nothing I imagined wouldn't work for the case when the else branch is dead :(. A patch that helps with bogus warning for dead then branches: --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1912,6 +1912,7 @@ collect_fallthrough_labels (gimple_stmt_iterator *gsi_p, if (gimple_code (gsi_stmt (*gsi_p)) == GIMPLE_COND) { gcond *cond_stmt = as_a <gcond *> (gsi_stmt (*gsi_p)); + bool false_p = gimple_cond_false_p (cond_stmt); tree false_lab = gimple_cond_false_label (cond_stmt); location_t if_loc = gimple_location (cond_stmt); @@ -1956,7 +1957,9 @@ collect_fallthrough_labels (gimple_stmt_iterator *gsi_p, = gimple_call_internal_p (gsi_stmt (*gsi_p), IFN_FALLTHROUGH); gsi_next (gsi_p); tree goto_dest = gimple_goto_dest (gsi_stmt (*gsi_p)); - if (!fallthru_before_dest) + /* If FALSE_P, the then branch is dead, do not collect + the label. */ + if (!fallthru_before_dest && !false_p) { struct label_entry l = { goto_dest, if_loc }; labels->safe_push (l);