https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94779
--- Comment #6 from Gabriel Ravier <gabravier at gmail dot com> --- There is another thing I realised : This code : int f1(unsigned x) { switch (x) { case 0: return 1; case 1: return 2; case 2: return 3; } } always gets optimized to `return x + 1;` with no problems. The switchconv pass handles it. Maybe that pass should be doing the same optimisation on the code from this issue, too. That seems like the simplest solution to this.