https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93505
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Bisection shows this started with my r8-3850-g39382c092ee9bb5c00330 change. If I change the testcase slightly (still -Og): unsigned a; unsigned foo (unsigned x) { unsigned y = __builtin_bswap64 (-a); x = x >> y | x << (-y & 31); x >>= 31; return x; } int main () { unsigned x = foo (~0); if (x != 1) __builtin_abort (); return 0; } it started in between r225210 and r227605, but have trouble building cross compilers in that range. Anyway, what happens is with the out of bounds rotate we get: Trying 13 -> 16: 13: r129:SI=r132:DI#0<-<0x20 REG_DEAD r132:DI 16: r123:DI=r129:SI<0 REG_DEAD r129:SI Successfully matched this instruction: (set (reg/v:DI 123 [ <retval> ]) (const_int 0 [0])) during combine. So, perhaps we could also change simplify-rtx.c to punt if it is out of bounds rather than trying to optimize anything.