https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54183
--- Comment #5 from Ruslan <b7.10110111 at gmail dot com> --- Yes, this is exactly the problem: the generic case is optimized while the special case, where the divisor is a compile-time constant, isn't.