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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:230b204d15b4b69bdf2741d6dbe5e8d80da5fa66

commit r17-6808-g230b204d15b4b69bdf2741d6dbe5e8d80da5fa66
Author: Jakub Jelinek <[email protected]>
Date:   Sun Nov 29 18:43:07 2026 +0100

    widen_mul: Avoid infinite loop in match_uaddc_usubc [PR129090]

    The following testcase hangs in match_uaddc_usubc.  We expect two
    different .ADD_OVERFLOW calls or two different .SUB_OVERFLOW calls
    (and later even verify that, one has to be chained to the other
    through IMAGPART_EXPR to one of the arguments dependency).
    The problem is that we make the assumption that there are 2 different
    calls already during the checking, it goes like
      for (int i = (ifn == IFN_ADD_OVERFLOW ? 1 : 0); i >= 0; --i)
        for (gimple *ovf = ovf1; ovf; ovf = (ovf == ovf1 ? ovf2 : NULL))
          {
            tree arg = gimple_call_arg (ovf, i);
    ...
    and the rest of the loop body has some code + one continue and one break.
    If we break, great, we found it, if we don't, for ovf1 != ovf2 this
    loops exactly twice per outer loop, first with ovf set to ovf1 and then
    with ovf set to ovf2.  If ovf1 == ovf2, this loops forever if it doesn't
    break (sure, it could be rewritten to do
        for (int j = 0; j < 2; j++)
          {
            tree ovf = j ? ovf2 : ovf1;
            tree arg = gimple_call_arg (ovf, i);
    ...
    But the ovf1 == ovf2 case is never going to match, so the following
    patch rejects it earlier.

    2026-11-29  Jakub Jelinek  <[email protected]>

            PR tree-optimization/129090
            * tree-ssa-math-opts.cc (match_uaddc_usubc): Punt if ovf1 == ovf2.

            * gcc.dg/pr129090.c: New test.

    Reviewed-by: Richard Biener <[email protected]>

Reply via email to