https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102738
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So this is interesting, I think clang/LLVM does this optimization late in their pipeline take: int a1(int f, int g) { if (f == 0 || f == 1) return (f-1) >> g; return 0; } They don't remove the shift at all. But if you change return 0 to __builtin_unreachable(), they remove the shift. Anyways we should be able to do this optimization even in the above case. And even here where clang/LLVM misses too: int a1(int f, int g) { if (f == 6 || f == 7) return (f-7) >> g; __builtin_unreachable(); }