public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/115281] New: [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129
@ 2024-05-29 16:44 rsandifo at gcc dot gnu.org
  2024-05-29 16:46 ` [Bug rtl-optimization/115281] " rsandifo at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-05-29 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115281
           Summary: [14/15 Regression] aarch64 ICE in go_through_subreg
                    after r14-5129
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
                CC: avieira at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64*-*-*

The following test ICEs with -O3 -mcpu=neoverse-v1 after r14-5129 (thanks to
Andre for the reproducer):

SUBROUTINE fn0(ma, mb, nt)
  CHARACTER ca
  REAL r0(ma)
  INTEGER i0(mb)
  REAL r1(3,mb)
  REAL r2(3,mb)
  REAL r3(3,3)
  zero=0.0
  do na = 1, nt
     nt = i0(na)
     do l = 1, 3
        r1 (l, na) =   r0 (nt)
        r2(l, na) = zero
     enddo
  enddo
  if (ca  .ne.'z') then
     do j = 1, 3
        do i = 1, 3
           r4  = zero
        enddo
     enddo
     do na = 1, nt
        do k =  1, 3
           do l = 1, 3
              do m = 1, 3
                 r3 = r4 * v
              enddo
           enddo
        enddo
     do i = 1, 3
           do k = 1, ifn (r3)
           enddo
        enddo
     enddo
     endif
END

The ICE is:

internal compiler error: in go_through_subreg, at ira-conflicts.cc:234
0x161647f go_through_subreg
        gnu/src/gcc/gcc/ira-conflicts.cc:234
0x1616657 process_regs_for_copy
        gnu/src/gcc/gcc/ira-conflicts.cc:270
0x1616fe8 process_reg_shuffles
        gnu/src/gcc/gcc/ira-conflicts.cc:440
0x1617b1b add_insn_allocno_copies
        gnu/src/gcc/gcc/ira-conflicts.cc:510
0x1617bcc add_copies
        gnu/src/gcc/gcc/ira-conflicts.cc:527
0x1600bed ira_traverse_loop_tree(bool, ira_loop_tree_node*, void
(*)(ira_loop_tree_node*), void (*)(ira_loop_tree_node*))
        gnu/src/gcc/gcc/ira-build.cc:1802
0x1618b38 ira_build_conflicts()
        gnu/src/gcc/gcc/ira-conflicts.cc:819
0x1605eb6 ira_build()
        gnu/src/gcc/gcc/ira-build.cc:3508
0x15fafe9 ira
        gnu/src/gcc/gcc/ira.cc:5793
0x15fba7f execute
        gnu/src/gcc/gcc/ira.cc:6117

I think this is a mode mix-up in go_through_subreg: we should be testing the
natural mode size of the REG that we're trying to split, rather than the mode
of the result.  (But we probably also need to handle paradoxical subregs
separately.)

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

* [Bug rtl-optimization/115281] [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129
  2024-05-29 16:44 [Bug rtl-optimization/115281] New: [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129 rsandifo at gcc dot gnu.org
@ 2024-05-29 16:46 ` rsandifo at gcc dot gnu.org
  2024-05-30 15:19 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-05-29 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.2
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
      Known to work|                            |13.1.0
      Known to fail|                            |14.1.0, 15.0
   Last reconfirmed|                            |2024-05-29
           Assignee|unassigned at gcc dot gnu.org      |rsandifo at gcc dot gnu.org

--- Comment #1 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
Testing a patch.

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

* [Bug rtl-optimization/115281] [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129
  2024-05-29 16:44 [Bug rtl-optimization/115281] New: [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129 rsandifo at gcc dot gnu.org
  2024-05-29 16:46 ` [Bug rtl-optimization/115281] " rsandifo at gcc dot gnu.org
@ 2024-05-30 15:19 ` cvs-commit at gcc dot gnu.org
  2024-05-30 15:22 ` [Bug rtl-optimization/115281] [14 " rsandifo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-30 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

https://gcc.gnu.org/g:46d931b3dd31cbba7c3355ada63f155aa24a4e2b

commit r15-929-g46d931b3dd31cbba7c3355ada63f155aa24a4e2b
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Thu May 30 16:17:58 2024 +0100

    ira: Fix go_through_subreg offset calculation [PR115281]

    go_through_subreg used:

      else if (!can_div_trunc_p (SUBREG_BYTE (x),
                                 REGMODE_NATURAL_SIZE (GET_MODE (x)), offset))

    to calculate the register offset for a pseudo subreg x.  In the blessed
    days before poly-int, this was:

        *offset = (SUBREG_BYTE (x) / REGMODE_NATURAL_SIZE (GET_MODE (x)));

    But I think this is testing the wrong natural size.  If we exclude
    paradoxical subregs (which will get an offset of zero regardless),
    it's the inner register that is being split, so it should be the
    inner register's natural size that we use.

    This matters in the testcase because we have an SFmode lowpart
    subreg into the last of three variable-sized vectors.  The
    SUBREG_BYTE is therefore equal to the size of two variable-sized
    vectors.  Dividing by the vector size gives a register offset of 2,
    as expected, but dividing by the size of a scalar FPR would give
    a variable offset.

    I think something similar could happen for fixed-size targets if
    REGMODE_NATURAL_SIZE is different for vectors and integers (say),
    although that case would trade an ICE for an incorrect offset.

    gcc/
            PR rtl-optimization/115281
            * ira-conflicts.cc (go_through_subreg): Use the natural size of
            the inner mode rather than the outer mode.

    gcc/testsuite/
            PR rtl-optimization/115281
            * gfortran.dg/pr115281.f90: New test.

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

* [Bug rtl-optimization/115281] [14 Regression] aarch64 ICE in go_through_subreg after r14-5129
  2024-05-29 16:44 [Bug rtl-optimization/115281] New: [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129 rsandifo at gcc dot gnu.org
  2024-05-29 16:46 ` [Bug rtl-optimization/115281] " rsandifo at gcc dot gnu.org
  2024-05-30 15:19 ` cvs-commit at gcc dot gnu.org
@ 2024-05-30 15:22 ` rsandifo at gcc dot gnu.org
  2024-06-11  8:59 ` cvs-commit at gcc dot gnu.org
  2024-06-11  8:59 ` rsandifo at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-05-30 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[14/15 Regression] aarch64  |[14 Regression] aarch64 ICE
                   |ICE in go_through_subreg    |in go_through_subreg after
                   |after r14-5129              |r14-5129
      Known to work|                            |15.0
      Known to fail|15.0                        |

--- Comment #3 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
Fixed on trunk, will backport if there are no issues.

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

* [Bug rtl-optimization/115281] [14 Regression] aarch64 ICE in go_through_subreg after r14-5129
  2024-05-29 16:44 [Bug rtl-optimization/115281] New: [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129 rsandifo at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-05-30 15:22 ` [Bug rtl-optimization/115281] [14 " rsandifo at gcc dot gnu.org
@ 2024-06-11  8:59 ` cvs-commit at gcc dot gnu.org
  2024-06-11  8:59 ` rsandifo at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-11  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Richard Sandiford
<rsandifo@gcc.gnu.org>:

https://gcc.gnu.org/g:7d64bc0990381221c480ba15cb9cc950e51e2cef

commit r14-10303-g7d64bc0990381221c480ba15cb9cc950e51e2cef
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Tue Jun 11 09:58:48 2024 +0100

    ira: Fix go_through_subreg offset calculation [PR115281]

    go_through_subreg used:

      else if (!can_div_trunc_p (SUBREG_BYTE (x),
                                 REGMODE_NATURAL_SIZE (GET_MODE (x)), offset))

    to calculate the register offset for a pseudo subreg x.  In the blessed
    days before poly-int, this was:

        *offset = (SUBREG_BYTE (x) / REGMODE_NATURAL_SIZE (GET_MODE (x)));

    But I think this is testing the wrong natural size.  If we exclude
    paradoxical subregs (which will get an offset of zero regardless),
    it's the inner register that is being split, so it should be the
    inner register's natural size that we use.

    This matters in the testcase because we have an SFmode lowpart
    subreg into the last of three variable-sized vectors.  The
    SUBREG_BYTE is therefore equal to the size of two variable-sized
    vectors.  Dividing by the vector size gives a register offset of 2,
    as expected, but dividing by the size of a scalar FPR would give
    a variable offset.

    I think something similar could happen for fixed-size targets if
    REGMODE_NATURAL_SIZE is different for vectors and integers (say),
    although that case would trade an ICE for an incorrect offset.

    gcc/
            PR rtl-optimization/115281
            * ira-conflicts.cc (go_through_subreg): Use the natural size of
            the inner mode rather than the outer mode.

    gcc/testsuite/
            PR rtl-optimization/115281
            * gfortran.dg/pr115281.f90: New test.

    (cherry picked from commit 46d931b3dd31cbba7c3355ada63f155aa24a4e2b)

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

* [Bug rtl-optimization/115281] [14 Regression] aarch64 ICE in go_through_subreg after r14-5129
  2024-05-29 16:44 [Bug rtl-optimization/115281] New: [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129 rsandifo at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-06-11  8:59 ` cvs-commit at gcc dot gnu.org
@ 2024-06-11  8:59 ` rsandifo at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-06-11  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

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

--- Comment #5 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2024-06-11  8:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-29 16:44 [Bug rtl-optimization/115281] New: [14/15 Regression] aarch64 ICE in go_through_subreg after r14-5129 rsandifo at gcc dot gnu.org
2024-05-29 16:46 ` [Bug rtl-optimization/115281] " rsandifo at gcc dot gnu.org
2024-05-30 15:19 ` cvs-commit at gcc dot gnu.org
2024-05-30 15:22 ` [Bug rtl-optimization/115281] [14 " rsandifo at gcc dot gnu.org
2024-06-11  8:59 ` cvs-commit at gcc dot gnu.org
2024-06-11  8:59 ` rsandifo 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).