https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117398
--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> --- (In reply to Sam James from comment #2) > * With just -O1, 11 works and >=12 fails, bisected to > r12-2591-g2e96b5f14e4025. > * With -O2 -fno-thread-jumps, 12 works and >=13 fails. Needs bisection I > guess. dont worry about bisecting. We aren't handling the case where all cases go to one lable, resulting in VARYING. we try to invert handled cases to remove them from the defalut case, but VARYING can't be inverted.. (neither VARYING nor UNDEFINED can be inverted as UNDEFINED has no type, so we cant call invert().invert() and get the original value back) so we trap I'll run this through testing, diff --git a/gcc/gimple-range-edge.cc b/gcc/gimple-range-edge.cc index e3a197a2293..31db631b349 100644 --- a/gcc/gimple-range-edge.cc +++ b/gcc/gimple-range-edge.cc @@ -159,8 +159,14 @@ gimple_outgoing_range::calc_switch_ranges (gswitch *sw) // Remove the case range from the default case. int_range_max def_range (type, low, high); range_cast (def_range, type); - def_range.invert (); - default_range.intersect (def_range); + // if all possible values are taken, set default_range to UNDEFINED. + if (def_range.varying_p ()) + default_range.set_undefined (); + else + { + def_range.invert (); + default_range.intersect (def_range); + } // Create/union this case with anything on else on the edge. int_range_max case_range (type, low, high);