https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112344

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>:

https://gcc.gnu.org/g:6bf66276e3e41d5d92f7b7260e98b6a111653805

commit r14-5759-g6bf66276e3e41d5d92f7b7260e98b6a111653805
Author: Richard Biener <rguent...@suse.de>
Date:   Wed Nov 22 11:10:41 2023 +0100

    tree-optimization/112344 - wrong final value replacement

    When performing final value replacement chrec_apply that's used to
    compute the overall effect of niters to a CHREC doesn't consider that
    the overall increment of { -2147483648, +, 2 } doesn't fit in
    a signed integer when the loop iterates until the value of the IV
    of 20.  The following fixes this mistake, carrying out the multiply
    and add in an unsigned type instead, avoiding undefined overflow
    and thus later miscompilation by path range analysis.

            PR tree-optimization/112344
            * tree-chrec.cc (chrec_apply): Perform the overall increment
            calculation and increment in an unsigned type.

            * gcc.dg/torture/pr112344.c: New testcase.

Reply via email to