public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096
@ 2020-12-24 18:28 asolokha at gmx dot com
  2020-12-27 18:46 ` [Bug rtl-optimization/98439] " ubizjak at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: asolokha at gmx dot com @ 2020-12-24 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98439
           Summary: [11 Regression] ICE in final_scan_insn_1, at
                    final.c:3096
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---
            Target: x86_64-unknown-linux-gnu

gcc-11.0.0-alpha20201220 snapshot (g:18e86fae2a14f78e70aae06afce6bb9853068bb1)
ICEs when compiling the following testcase w/ -march=nehalem -O2
-fselective-scheduling2 -fno-cprop-registers:

int in;

int
wz (int, int, int, int, int, int, int);

int
w5 (void)
{
  return wz (0, 0, 0, 0, 0, 0, in > 0 ? in : 0);
}

% x86_64-unknown-linux-gnu-gcc-11.0.0 -march=nehalem -O2
-fselective-scheduling2 -fno-cprop-registers -c jpl1fnqa.c
during RTL pass: final
jpl1fnqa.c: In function 'w5':
jpl1fnqa.c:10:1: internal compiler error: in final_scan_insn_1, at final.c:3096
   10 | }
      | ^
0x64eefe final_scan_insn_1
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201220/work/gcc-11-20201220/gcc/final.c:3096
0xa985ab final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201220/work/gcc-11-20201220/gcc/final.c:3170
0xa986a7 final_1
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201220/work/gcc-11-20201220/gcc/final.c:2021
0xa99294 rest_of_handle_final
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201220/work/gcc-11-20201220/gcc/final.c:4676
0xa99294 execute
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201220/work/gcc-11-20201220/gcc/final.c:4754

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
@ 2020-12-27 18:46 ` ubizjak at gmail dot com
  2020-12-27 18:55 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2020-12-27 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |rtl-optimization
   Last reconfirmed|                            |2020-12-27
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Confirmed as rtl-optimization problem.

Before sched2 pass, we have:

(insn 26 7 8 2 (set (reg:SI 0 ax [85])
        (reg:SI 20 xmm0 [89])) "pr98439.c":9:10 75 {*movsi_internal}

(insn 8 26 39 2 (set (mem:SI (pre_modify:DI (reg/f:DI 7 sp)
                (plus:DI (reg/f:DI 7 sp)
                    (const_int -8 [0xfffffffffffffff8]))) [0  S4 A32])
        (reg:SI 0 ax [85])) "pr98439.c":9:10 53 {*pushsi2_rex64}

which is transformed by sched2 pass to:

(insn:TI 46 44 26 2 (set (mem:SI (pre_modify:DI (reg/f:DI 7 sp)
                (plus:DI (reg/f:DI 7 sp)
                    (const_int -8 [0xfffffffffffffff8]))) [0  S4 A32])
        (reg:SI 20 xmm0 [89])) 53 {*pushsi2_rex64}

(insn 26 46 15 2 (set (reg:SI 0 ax [85])
        (reg:SI 20 xmm0 [89])) "pr98439.c":9:10 75 {*movsi_internal}

(insn 46) is defined in i386.md as:

(define_insn "*pushsi2_rex64"
  [(set (match_operand:SI 0 "push_operand" "=X,X")
        (match_operand:SI 1 "nonmemory_no_elim_operand" "re,*v"))]
  "TARGET_64BIT"
  "@
   push{q}\t%q1
   #"
  [(set_attr "type" "push,multi")
   (set_attr "mode" "DI")])

xmm0 is allowed by *v constraint, but the insn has to be split. Since sched2
pass comes after split3 pass, we hit the assert in final_scan_insn_1:

        /* If the template is the string "#", it means that this insn must
           be split.  */
        if (templ[0] == '#' && templ[1] == '\0')
          {
            rtx_insn *new_rtx = try_split (body, insn, 0);

            /* If we didn't split the insn, go away.  */
            if (new_rtx == insn && PATTERN (new_rtx) == body)
              fatal_insn ("could not split insn", insn);

            /* If we have a length attribute, this instruction should have
               been split in shorten_branches, to ensure that we would have
               valid length info for the splitees.  */
-->         gcc_assert (!HAVE_ATTR_length);

            return new_rtx;
          }

As the comment says, this insn should have been split in shorten_branches, but:

      /* The placement of the splitting that we do for shorten_branches
         depends on whether regstack is used by the target or not.  */
#if HAVE_ATTR_length && !defined (STACK_REGS)
      return true;
#else
      return false;
#endif

and nothing splits insns after sched2, because:

bool
pass_split_before_regstack::gate (function *)
{
#if HAVE_ATTR_length && defined (STACK_REGS)
  /* If flow2 creates new instructions which need splitting
     and scheduling after reload is not done, they might not be
     split until final which doesn't allow splitting
     if HAVE_ATTR_length.  */
  return !enable_split_before_sched2 ();
#else
  return false;
#endif
}

and finally:

static bool
enable_split_before_sched2 (void)
{
#ifdef INSN_SCHEDULING
  return optimize > 0 && flag_schedule_insns_after_reload;
#else
  return false;
#endif
}

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
  2020-12-27 18:46 ` [Bug rtl-optimization/98439] " ubizjak at gmail dot com
@ 2020-12-27 18:55 ` jakub at gcc dot gnu.org
  2020-12-28 11:19 ` ubizjak at gmail dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-27 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

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> ---
I'd say that is a backend bug that perhaps need some middle-end help,
in particular the last split pass should set some flag and insns that require
splitting should check that flag to avoid matching after the last splitting.

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
  2020-12-27 18:46 ` [Bug rtl-optimization/98439] " ubizjak at gmail dot com
  2020-12-27 18:55 ` jakub at gcc dot gnu.org
@ 2020-12-28 11:19 ` ubizjak at gmail dot com
  2021-01-14  8:10 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2020-12-28 11:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
I don't think this is a backend bug. The position of split pass in the pass
sequence assumes that no split candidates will be emitted after regstack, as
can be seen from the gate function of the pass_split_for_shorten_branches (aka
split5) pass:

      /* The placement of the splitting that we do for shorten_branches
         depends on whether regstack is used by the target or not.  */
#if HAVE_ATTR_length && !defined (STACK_REGS)
      return true;
#else
      return false;
#endif

However, with INSN_SCHEDULING, the pass_split_before_regstack (aka split4) pass
gets moved before sched2 pass as the pass_data_split_before_sched2 (aka
split3). The assumption here is that sched2 pass won't emit split candidates,
which is apparently not true with -fselective-scheduling2.

Without STACK_REGS, these insns will be split in split5, but it looks to me
that for STACK_REGS targets, split4 pass has to be run when
flag_selective_scheduling2 is in effect.

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2020-12-28 11:19 ` ubizjak at gmail dot com
@ 2021-01-14  8:10 ` rguenth at gcc dot gnu.org
  2021-01-14 11:13 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14  8:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2021-01-14  8:10 ` rguenth at gcc dot gnu.org
@ 2021-01-14 11:13 ` rguenth at gcc dot gnu.org
  2021-01-14 11:18 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2021-01-14 11:13 ` rguenth at gcc dot gnu.org
@ 2021-01-14 11:18 ` jakub at gcc dot gnu.org
  2021-02-12 15:50 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-14 11:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So shell we schedule another split pass for this case?

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2021-01-14 11:18 ` jakub at gcc dot gnu.org
@ 2021-02-12 15:50 ` jakub at gcc dot gnu.org
  2021-02-13 15:09 ` cvs-commit at gcc dot gnu.org
  2021-02-13 15:13 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-12 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

Untested fix.

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
                   ` (6 preceding siblings ...)
  2021-02-12 15:50 ` jakub at gcc dot gnu.org
@ 2021-02-13 15:09 ` cvs-commit at gcc dot gnu.org
  2021-02-13 15:13 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-13 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:05402ca65a6696a8f20a3dbcb18f47ba3bdfa268

commit r11-7235-g05402ca65a6696a8f20a3dbcb18f47ba3bdfa268
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Feb 13 16:08:29 2021 +0100

    passes: Enable split4 with selective scheduling 2 [PR98439]

    As mentioned in the PR, we have 5 split passes (+ splitting during final).
    split1 is before RA and is unconditional,
    split2 is after RA and is gated on optimize > 0,
    split3 is before sched2 and is gated on
      defined(INSN_SCHEDULING) && optimize > 0 &&
flag_schedule_insns_after_reload
    split4 is before regstack and is gated on
      HAVE_ATTR_length && defined (STACK_REGS) && !gate (split3)
    split5 is before shorten_branches and is gated on
      HAVE_ATTR_length && !defined (STACK_REGS)
    and the splitting during final works only when !HAVE_ATTR_length.
    STACK_REGS is a macro enabled only on i386/x86_64.

    The problem with the following testcase is that split3 before sched2
    is the last splitting pass for the target/command line options set,
    but selective scheduling unlike normal scheduling can create new
    instructions that need to be split, which means we ICE during final as
    there are insns that require splitting but nothing split them.

    This patch fixes it by doing split4 also when -fselective-scheduling2
    is enabled on x86 and split3 has been run.  As that option isn't on
    by default, it should slow down compilation only for those that enable
    that option.

    2021-02-13  Jakub Jelinek  <jakub@redhat.com>

            PR rtl-optimization/98439
            * recog.c (pass_split_before_regstack::gate): Enable even when
            pass_split_before_sched2 is enabled if -fselective-scheduling2 is
            on.

            * gcc.target/i386/pr98439.c: New test.

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

* [Bug rtl-optimization/98439] [11 Regression] ICE in final_scan_insn_1, at final.c:3096
  2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
                   ` (7 preceding siblings ...)
  2021-02-13 15:09 ` cvs-commit at gcc dot gnu.org
@ 2021-02-13 15:13 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-13 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2021-02-13 15:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-24 18:28 [Bug target/98439] New: [11 Regression] ICE in final_scan_insn_1, at final.c:3096 asolokha at gmx dot com
2020-12-27 18:46 ` [Bug rtl-optimization/98439] " ubizjak at gmail dot com
2020-12-27 18:55 ` jakub at gcc dot gnu.org
2020-12-28 11:19 ` ubizjak at gmail dot com
2021-01-14  8:10 ` rguenth at gcc dot gnu.org
2021-01-14 11:13 ` rguenth at gcc dot gnu.org
2021-01-14 11:18 ` jakub at gcc dot gnu.org
2021-02-12 15:50 ` jakub at gcc dot gnu.org
2021-02-13 15:09 ` cvs-commit at gcc dot gnu.org
2021-02-13 15:13 ` 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).