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

--- Comment #4 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:24ea113f75cfad38894dc1ad16b23c0538ef17d4

commit r11-6610-g24ea113f75cfad38894dc1ad16b23c0538ef17d4
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Jan 12 11:04:46 2021 +0100

    widening_mul: Fix up ICE caused by my signed multiplication overflow
pattern recognition changes [PR98629]

    As the testcase shows, my latest changes caused ICE on that testcase.
    The problem is that arith_overflow_check_p now can change the use_stmt
    argument (has a reference), so that if it succeeds (returns non-zero),
    it points it to the GIMPLE_COND or EQ/NE or COND_EXPR assignment from the
    TRUNC_DIV_EXPR assignment.
    The problem was that it would change use_stmt also if it returned 0 in some
    cases, such as multiple imm uses of the division, and in one of the callers
    if arith_overflow_check_p returns 0 it looks at use_stmt again and performs
    other checks, which of course assumes that use_stmt is the one passed
    to arith_overflow_check_p and not e.g. NULL instead or some other unrelated
    stmt.

    The following patch fixes that by only changing use_stmt when we are about
    to return non-zero (for the MULT_EXPR case, which is the only one with the
    need to use different use_stmt).

    2021-01-12  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/98629
            * tree-ssa-math-opts.c (arith_overflow_check_p): Don't update
use_stmt
            unless returning non-zero.

            * gcc.c-torture/compile/pr98629.c: New test.

Reply via email to