On Mon, Sep 02, 2024 at 09:03:46AM +0200, Richard Biener wrote:
> > I have originally thought about solving this problem in the switch 
> > conversion
> > pass.  However, I think that would require basically detecting that the 
> > "take
> > away the default case" transformation happened and then reversing it.  That
> > seems pretty messy to me.  Also, as I already mentioned, I think that the
> > canonical representation of this kind of switches should be some 
> > representation
> > that marks the default case as unreachable (with __builtin_unreachable or
> > somehow else).
> 
> But can you not simply look at the switch expression range to derive the same
> knowledge as with the unreachable in default?

I think we have some open PRs that the switch lowering should use range
information, e.g. PR89059.
Just computing the range at the GIMPLE_SWITCH and lowering as if only the
in-range cases were present is one thing, but there is also the problem that
we often lower the switch prematurely e.g. into a table lookup etc. (which
is nice for e.g. inlining heuristics, sure) but after inlining we aren't
able to update that and based on more precise range perhaps reconsider the
lowering kind.

        Jakub

Reply via email to