On 9/1/24 9:19 AM, Filip Kastl wrote:
(I'm Cc-ing Diego since he originally contributed the VRP pass and Jeff because
I've seen him in git blame on many lines of vr-values.cc around the place I
would like to make modifications)
Hello,
In this RFC I'd like to propose the following: When the value range statement
simplification machinery encounters a switch with a default case that never
executes, it should mark the default case with __builtin_unreachable instead of
removing the default case. I think that should be the "canonical"
representation of switches with this property.
In terms of changes made to GCC code, this would be a small patch.
I'd like to hear other people's opinions on this. Perhaps there are
implications of this change or some other issues with the idea which I don't
see.
The right thing to do is to eliminate the unreachable code. We don't
replace the body of an if (0) with a __builtin_unreachable. We remove
it. Switch statements should be no different here.
If that inhibits later analysis or optimization then that's an indicator
that we need to improve our frameworks, not that we should keep dead
code lying around in the IL.
Jeff