https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112629

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note we could do it even for unsigned if we know that (a+4) will not wrap.

That is:
```
#include <limits.h>

int optimized_shift(unsigned shift) {
   if ((shift < 0) | (shift > (unsigned)INT_MAX)) __builtin_unreachable();
    return 1 << (shift + 4);
}
```

LLVM is able to handle both cases.

Reply via email to