https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95853
--- Comment #2 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:c1fb592f2c3c6b5a6616cf882ce24d30e167a646 commit r11-5238-gc1fb592f2c3c6b5a6616cf882ce24d30e167a646 Author: Jakub Jelinek <ja...@redhat.com> Date: Sun Nov 22 19:16:34 2020 +0100 widening_mul: pattern recognize further forms of __builtin_add_overflow [PR95853] The following patch recognizes some further forms of additions with overflow checks as shown in the testcase, in particular where the unsigned addition is performed in a wider mode just to catch overflow with a > narrower_utype_max check. 2020-11-22 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/95853 * tree-ssa-math-opts.c (uaddsub_overflow_check_p): Add maxval argument, if non-NULL, instead look for r > maxval or r <= maxval comparisons. (match_uaddsub_overflow): Pattern recognize even other forms of __builtin_add_overflow, in particular when addition is performed in a wider type and result compared to maximum of the narrower type. * gcc.dg/pr95853.c: New test.