https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85726
Bug ID: 85726 Summary: div C1 to div C2 match.pd suboptimization Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hp at gcc dot gnu.org Target Milestone: --- See the attached test-case, ready to drop into testsuite/gcc.dg. The suboptimization results in separate div and mod sequences across all architectures where division or modulus by a constant is implemented as a widened multiplication and right-shift (actually most; at least x86_64, mips, ppc, aarch64). The test-case doesn't fail for e.g. sparc, that doesn't do it that way. This is a somewhat long-standing suboptimality, but a regression. The title hints at the cause and solution; patch to be posted.