public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939
@ 2020-10-19  9:28 asolokha at gmx dot com
  2020-10-19  9:47 ` [Bug middle-end/97487] " rguenth at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: asolokha at gmx dot com @ 2020-10-19  9:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97487
           Summary: [10/11 Regression] ICE in expand_simple_binop, at
                    optabs.c:939
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---

gcc-11.0.0-alpha20201018 snapshot (g:1e70b1a358b6ce3b894f284d88fbb90518d45cc0)
ICEs when compiling the following testcase w/ -O3 --param
max-rtl-if-conversion-unpredictable-cost=0:

long int __attribute__ ((simd))
i1 (long int kt, long int sg)
{
  return kt < 0 ? sg : 0;
}

% gcc-11.0.0 -O3 --param max-rtl-if-conversion-unpredictable-cost=0 -c
xaw8sf5n.c
during RTL pass: ce1
xaw8sf5n.c: In function 'i1.simdclone.0':
xaw8sf5n.c:5:1: internal compiler error: in expand_simple_binop, at
optabs.c:939
    5 | }
      | ^
0x69936d expand_simple_binop(machine_mode, rtx_code, rtx_def*, rtx_def*,
rtx_def*, int, optab_methods)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/optabs.c:939
0x69936d expand_simple_binop(machine_mode, rtx_code, rtx_def*, rtx_def*,
rtx_def*, int, optab_methods)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/optabs.c:934
0xa65578 force_operand(rtx_def*, rtx_def*)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/expr.c:7720
0xa3baea copy_to_mode_reg(machine_mode, rtx_def*)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/explow.c:629
0xca49bb maybe_legitimize_operand
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/optabs.c:7199
0xca49bb maybe_legitimize_operands(insn_code, unsigned int, unsigned int,
expand_operand*)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/optabs.c:7331
0xca1c09 maybe_gen_insn(insn_code, unsigned int, expand_operand*)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/optabs.c:7350
0xca74ad expand_binop_directly
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/optabs.c:1122
0xca5b2f expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*,
int, optab_methods)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/optabs.c:1209
0x17a9183 noce_try_sign_mask
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/ifcvt.c:2780
0x17a9183 noce_process_if_block
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/ifcvt.c:3610
0x17a9183 noce_find_if_block
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/ifcvt.c:4075
0x17a9183 find_if_header
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/ifcvt.c:4280
0x17a9183 if_convert
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/ifcvt.c:5413
0x17a92b1 rest_of_handle_if_conversion
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/ifcvt.c:5478
0x17a92b1 execute
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201018/work/gcc-11-20201018/gcc/ifcvt.c:5518

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
@ 2020-10-19  9:47 ` rguenth at gcc dot gnu.org
  2020-10-19 12:13 ` [Bug middle-end/97487] [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r10-1420-g744fd446c321f78f marxin at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-19  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.3
           Keywords|                            |openmp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r10-1420-g744fd446c321f78f
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
  2020-10-19  9:47 ` [Bug middle-end/97487] " rguenth at gcc dot gnu.org
@ 2020-10-19 12:13 ` marxin at gcc dot gnu.org
  2020-10-19 17:57 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-19 12:13 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11 Regression] ICE in   |[10/11 Regression] ICE in
                   |expand_simple_binop, at     |expand_simple_binop, at
                   |optabs.c:939                |optabs.c:939 since
                   |                            |r10-1420-g744fd446c321f78f
   Last reconfirmed|                            |2020-10-19
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |10.2.0, 11.0
      Known to work|                            |9.3.0
     Ever confirmed|0                           |1
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r10-1420-g744fd446c321f78f.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r10-1420-g744fd446c321f78f
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
  2020-10-19  9:47 ` [Bug middle-end/97487] " rguenth at gcc dot gnu.org
  2020-10-19 12:13 ` [Bug middle-end/97487] [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r10-1420-g744fd446c321f78f marxin at gcc dot gnu.org
@ 2020-10-19 17:57 ` jakub at gcc dot gnu.org
  2020-10-20  8:13 ` [Bug middle-end/97487] [8/9/10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977 jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-10-19 17:57 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
ifcvt throws random expressions as operand to expand_binop, which in turn
attempts to force_operand them, but force_operand handles only the most common
rtls (e.g. for binops only those that have corresponding binop optab, similarly
for unops etc.).
In this case the SET_SRC and thus if_info->b is a VEC_SELECT which
force_operand isn't able to handle (but there are many others that can't be
handled either).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9/10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2020-10-19 17:57 ` jakub at gcc dot gnu.org
@ 2020-10-20  8:13 ` jakub at gcc dot gnu.org
  2021-01-14  9:26 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-10-20  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|openmp                      |
            Summary|[10/11 Regression] ICE in   |[8/9/10/11 Regression] ICE
                   |expand_simple_binop, at     |in expand_simple_binop, at
                   |optabs.c:939 since          |optabs.c:939 since r8-3977
                   |r10-1420-g744fd446c321f78f  |

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Also, the PR has nothing to do with OpenMP:
-O2 --param max-rtl-if-conversion-unpredictable-cost=0 on x86_64-linux ICEs
too:
typedef long long int V __attribute__((vector_size (16)));

long long int
foo (V x, V y)
{
  long long int t1 = y[0];
  long long int t2 = x[0];
  long long int t3;
  if (t2 < 0)
    t3 = t1;
  else
    t3 = 0;
  return t3;
}
And that started with r8-3977-gef9eec0b599d533b58e29fe0c0bf6435e5368378 (latent
before because of different costs).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9/10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2020-10-20  8:13 ` [Bug middle-end/97487] [8/9/10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977 jakub at gcc dot gnu.org
@ 2021-01-14  9:26 ` rguenth at gcc dot gnu.org
  2021-02-01 16:45 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14  9:26 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
             Target|                            |x86_64-*-*

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9/10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2021-01-14  9:26 ` rguenth at gcc dot gnu.org
@ 2021-02-01 16:45 ` jakub at gcc dot gnu.org
  2021-02-03  8:10 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-01 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50112
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50112&action=edit
gcc11-pr97487.patch

Untested fix.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9/10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2021-02-01 16:45 ` jakub at gcc dot gnu.org
@ 2021-02-03  8:10 ` cvs-commit at gcc dot gnu.org
  2021-02-03  8:12 ` [Bug middle-end/97487] [8/9/10 " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-03  8:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:176c7bd840a3902e9e67eb0796de362677905f56

commit r11-7052-g176c7bd840a3902e9e67eb0796de362677905f56
Author: Jakub Jelinek <jakub@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  <jakub@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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9/10 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (6 preceding siblings ...)
  2021-02-03  8:10 ` cvs-commit at gcc dot gnu.org
@ 2021-02-03  8:12 ` jakub at gcc dot gnu.org
  2021-03-19 23:28 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-03  8:12 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10/11 Regression] ICE  |[8/9/10 Regression] ICE in
                   |in expand_simple_binop, at  |expand_simple_binop, at
                   |optabs.c:939 since r8-3977  |optabs.c:939 since r8-3977

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9/10 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (7 preceding siblings ...)
  2021-02-03  8:12 ` [Bug middle-end/97487] [8/9/10 " jakub at gcc dot gnu.org
@ 2021-03-19 23:28 ` cvs-commit at gcc dot gnu.org
  2021-03-20  8:06 ` [Bug middle-end/97487] [8/9 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-19 23:28 UTC (permalink / raw)
  To: gcc-bugs

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
<jakub@gcc.gnu.org>:

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

commit r10-9463-g025a0ee3911c0866c69f841df24a558c7c8df0eb
Author: Jakub Jelinek <jakub@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  <jakub@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)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (8 preceding siblings ...)
  2021-03-19 23:28 ` cvs-commit at gcc dot gnu.org
@ 2021-03-20  8:06 ` jakub at gcc dot gnu.org
  2021-04-20 23:32 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-20  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10 Regression] ICE in  |[8/9 Regression] ICE in
                   |expand_simple_binop, at     |expand_simple_binop, at
                   |optabs.c:939 since r8-3977  |optabs.c:939 since r8-3977
   Target Milestone|10.3                        |8.5

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10.3 too.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (9 preceding siblings ...)
  2021-03-20  8:06 ` [Bug middle-end/97487] [8/9 " jakub at gcc dot gnu.org
@ 2021-04-20 23:32 ` cvs-commit at gcc dot gnu.org
  2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org
  2021-04-22 17:07 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20 23:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:e55dc66ddefebef79f8d733ba6eb835c7b52d7ec

commit r9-9415-ge55dc66ddefebef79f8d733ba6eb835c7b52d7ec
Author: Jakub Jelinek <jakub@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  <jakub@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 025a0ee3911c0866c69f841df24a558c7c8df0eb)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (10 preceding siblings ...)
  2021-04-20 23:32 ` cvs-commit at gcc dot gnu.org
@ 2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org
  2021-04-22 17:07 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-22 16:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:0afc3f561b5cf66d1ee9562369919ca19273c260

commit r8-10880-g0afc3f561b5cf66d1ee9562369919ca19273c260
Author: Jakub Jelinek <jakub@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  <jakub@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 025a0ee3911c0866c69f841df24a558c7c8df0eb)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/97487] [8/9 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977
  2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
                   ` (11 preceding siblings ...)
  2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org
@ 2021-04-22 17:07 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-22 17:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-04-22 17:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19  9:28 [Bug middle-end/97487] New: [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 asolokha at gmx dot com
2020-10-19  9:47 ` [Bug middle-end/97487] " rguenth at gcc dot gnu.org
2020-10-19 12:13 ` [Bug middle-end/97487] [10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r10-1420-g744fd446c321f78f marxin at gcc dot gnu.org
2020-10-19 17:57 ` jakub at gcc dot gnu.org
2020-10-20  8:13 ` [Bug middle-end/97487] [8/9/10/11 Regression] ICE in expand_simple_binop, at optabs.c:939 since r8-3977 jakub at gcc dot gnu.org
2021-01-14  9:26 ` rguenth at gcc dot gnu.org
2021-02-01 16:45 ` jakub at gcc dot gnu.org
2021-02-03  8:10 ` cvs-commit at gcc dot gnu.org
2021-02-03  8:12 ` [Bug middle-end/97487] [8/9/10 " jakub at gcc dot gnu.org
2021-03-19 23:28 ` cvs-commit at gcc dot gnu.org
2021-03-20  8:06 ` [Bug middle-end/97487] [8/9 " jakub at gcc dot gnu.org
2021-04-20 23:32 ` cvs-commit at gcc dot gnu.org
2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org
2021-04-22 17:07 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).