https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87203
Bug ID: 87203 Summary: Optimize x % constant ==/!= 0 Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- As mentioned in http://duriansoftware.com/joe/Optimizing-is-multiple-checks-with-modular-arithmetic.html , we could optimize unsigned x % const == 0 or x % const != 0 into a single (non-highpart) multiplication plus comparison (at least for odd const, for even const we can rotate before comparison if target has cheap rotates, or could test low bits and compare). Obviously, for power of two const we already emit the best code.