https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95852
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:a2106317cd6673e110b347c70f21e25fbb23379e commit r11-6579-ga2106317cd6673e110b347c70f21e25fbb23379e Author: Jakub Jelinek <ja...@redhat.com> Date: Mon Jan 11 10:32:07 2021 +0100 widening_mul: Pattern recognize unsigned multiplication with overflow check [PR95852] The following patch pattern recognizes some forms of multiplication followed by overflow check through division by one of the operands compared to the other one, with optional removal of guarding non-zero check for that operand if possible. The patterns are replaced with effectively __builtin_mul_overflow or __builtin_mul_overflow_p. The testcases cover 64 different forms of that. 2021-01-11 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/95852 * tree-ssa-math-opts.c (maybe_optimize_guarding_check): New function. (uaddsub_overflow_check_p): Renamed to ... (arith_overflow_check_p): ... this. Handle also multiplication with overflow check. (match_uaddsub_overflow): Renamed to ... (match_arith_overflow): ... this. Add cfg_changed argument. Handle also multiplication with overflow check. Adjust function comment. (math_opts_dom_walker::after_dom_children): Adjust callers. Call match_arith_overflow also for MULT_EXPR. * gcc.target/i386/pr95852-1.c: New test. * gcc.target/i386/pr95852-2.c: New test.