https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104992
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Sam Feifer <sfei...@gcc.gnu.org>: https://gcc.gnu.org/g:388fbbd895e72669909173c3003ae65c6483a3c2 commit r13-1916-g388fbbd895e72669909173c3003ae65c6483a3c2 Author: Sam Feifer <sfei...@redhat.com> Date: Fri Jul 29 09:44:48 2022 -0400 match.pd: Add new division pattern [PR104992] This patch fixes a missed optimization in match.pd. It takes the pattern, x / y * y == x, and optimizes it to x % y == 0. This produces fewer instructions. This simplification does not happen for complex types. This patch also adds tests for the optimization rule. Bootstrapped/regtested on x86_64-pc-linux-gnu. PR tree-optimization/104992 gcc/ChangeLog: * match.pd (x / y * y == x): New simplification. gcc/testsuite/ChangeLog: * g++.dg/pr104992-1.C: New test. * gcc.dg/pr104992.c: New test.