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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:025a0ee3911c0866c69f841df24a558c7c8df0eb

commit r10-9463-g025a0ee3911c0866c69f841df24a558c7c8df0eb
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Feb 3 09:09:26 2021 +0100

    ifcvt: Avoid ICEs trying to force_operand random RTL [PR97487]

    As the testcase shows, RTL ifcvt can throw random RTL (whatever it found in
    some insns) at expand_binop or expand_unop and expects it to do something
    (and then will check if it created valid insns and punts if not).
    These functions in the end if the operands don't match try to
    copy_to_mode_reg the operands, which does
    if (!general_operand (x, VOIDmode))
      x = force_operand (x, temp);
    but, force_operand is far from handling all possible RTLs, it will ICE for
    all more unusual RTL codes.  Basically handles just simple arithmetic and
    unary RTL operations if they have an optab and
    expand_simple_binop/expand_simple_unop ICE on others.

    The following patch fixes it by adding some operand verification (whether
    there is a hope that copy_to_mode_reg will succeed on those).  It is added
    both to noce_emit_move_insn (not needed for this exact testcase,
    that function simply tries to recog the insn as is and if it fails,
    handles some simple binop/unop cases; the patch performs the verification
    of their operands) and noce_try_sign_mask.

    2021-02-03  Jakub Jelinek  <ja...@redhat.com>

            PR middle-end/97487
            * ifcvt.c (noce_can_force_operand): New function.
            (noce_emit_move_insn): Use it.
            (noce_try_sign_mask): Likewise.  Formatting fix.

            * gcc.dg/pr97487-1.c: New test.
            * gcc.dg/pr97487-2.c: New test.

    (cherry picked from commit 176c7bd840a3902e9e67eb0796de362677905f56)

Reply via email to