On Sun 2024-09-01 09:25:07, Jeff Law wrote:
> 
> 
> 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
> 
> 

I see.  This is not the way forward.  While reading your reply it occured to me
that it could be possible to use value range info in switch conversion to get
the switches in question optimized without relying on __bultin_unreachable.
I'll try that.

Thanks,
Filip

Reply via email to