https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94789
Wilco <wilco at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wilco at gcc dot gnu.org --- Comment #4 from Wilco <wilco at gcc dot gnu.org> --- (In reply to Gabriel Ravier from comment #0) > int r(int x, unsigned b) > { > int const m = CHAR_BIT * sizeof(x) - b; > return (x << m); > } > > `CHAR_BIT * sizeof(x) - b;` can be optimized to `-b`. LLVM does this > transformation, not GCC. > > Comparison here : https://godbolt.org/z/5byJ2E AArch64 already generates: neg w1, w1 lsl w0, w0, w1 ret