https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82418
Bug ID: 82418 Summary: Division on a constant is suboptimal because of not using imul instruction Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- Following code unsigned my_div(unsigned a, unsigned b) { return a / 100; } Produces assembly: my_div(unsigned int, unsigned int): mov eax, edi mov edx, 1374389535 mul edx mov eax, edx shr eax, 5 ret Clang uses imul instead: my_div(unsigned int, unsigned int): # @my_div(unsigned int, unsigned int) mov eax, edi imul rax, rax, 1374389535 shr rax, 37 ret